27 #ifndef _TOMOGRAPHER_MHRW_H
28 #define _TOMOGRAPHER_MHRW_H
37 #include <type_traits>
84 template<
typename RandomWalk_>
87 typedef RandomWalk_ RandomWalk;
88 typedef typename RandomWalk::CountIntType CountIntType;
97 static void run(RandomWalk & rw)
99 const CountIntType Nsweep = rw.n_sweep();
100 const CountIntType Ntherm = rw.n_therm();
101 const CountIntType Nrun = rw.n_run();
107 const CountIntType num_thermalize = Nsweep*Ntherm;
109 for (k = 0; k < num_thermalize; ++k) {
111 rw.move(k,
true,
false);
115 rw.thermalizing_done();
117 const CountIntType num_run = Nsweep*Nrun;
121 for (k = 0; k < num_run; ++k) {
123 bool is_live_iter = ((k+1) % Nsweep == 0);
126 rw.move(k,
false, is_live_iter);
129 rw.process_sample(k, n);
170 namespace tomo_internal {
179 template<
typename MHWalker,
int UseFnSyntaxType>
180 struct MHRandomWalk_helper_decide_jump
185 typedef typename MHWalker::PointType PointType;
189 typedef typename MHWalker::FnValueType FnValueType;
197 static inline FnValueType get_ptval(MHWalker & mhwalker,
const PointType & curpt)
199 (void)mhwalker; (void)curpt;
200 assert(0 &&
"UNKNOWN UseFnSyntaxType: Not implemented");
215 static inline double get_a_value(MHWalker & ,
const PointType & , FnValueType ,
216 const PointType & , FnValueType )
218 assert(0 &&
"UNKNOWN UseFnSyntaxType: Not implemented");
226 template<
typename MHWalker>
227 struct MHRandomWalk_helper_decide_jump<MHWalker,
MHUseFnValue>
229 typedef typename MHWalker::PointType PointType;
230 typedef typename MHWalker::FnValueType FnValueType;
232 static inline FnValueType get_ptval(MHWalker & mhwalker,
const PointType & curpt)
234 return mhwalker.fnval(curpt);
236 static inline double get_a_value(MHWalker & ,
const PointType & ,
double newptval,
237 const PointType & ,
double curptval)
239 return (newptval / curptval);
246 template<
typename MHWalker>
249 typedef typename MHWalker::PointType PointType;
250 typedef typename MHWalker::FnValueType FnValueType;
252 static inline FnValueType get_ptval(MHWalker & mhwalker,
const PointType & curpt)
254 return mhwalker.fnlogval(curpt);
256 static inline double get_a_value(MHWalker & ,
const PointType & , FnValueType newptval,
257 const PointType & , FnValueType curptval)
259 return (newptval > curptval) ? 1.0 :
exp(newptval - curptval);
266 template<
typename MHWalker>
269 typedef typename MHWalker::PointType PointType;
270 typedef int FnValueType;
272 static inline FnValueType get_ptval(MHWalker & ,
const PointType & )
276 static inline double get_a_value(MHWalker & mhwalker,
const PointType & newpt, FnValueType ,
277 const PointType & curpt, FnValueType )
279 return mhwalker.fnrelval(newpt, curpt);
301 template<
typename Rng_,
typename MHWalker_,
typename MHRWStatsCollector_,
typename LoggerType_,
302 typename CountIntType_ =
unsigned int>
323 #ifndef TOMOGRAPHER_PARSED_BY_DOXYGEN
324 typedef typename tomo_internal::MHRandomWalk_helper_decide_jump<MHWalker,MHWalker::UseFnSyntaxType>::FnValueType
336 const CountIntType _n_sweep;
337 const CountIntType _n_therm;
338 const CountIntType _n_run;
339 const RealScalar _step_size;
342 MHWalker & _mhwalker;
343 MHRWStatsCollector & _stats;
344 LoggerType & _logger;
351 FnValueType curptval;
357 CountIntType num_accepted;
361 CountIntType num_live_points;
367 MHWalker & mhwalker, MHRWStatsCollector & stats,
368 Rng & rng, LoggerType & logger_)
369 : _n_sweep(n_sweep), _n_therm(n_therm), _n_run(n_run),
370 _step_size(step_size),
380 _logger.debug(
"MHRandomWalk",
"constructor(). n_sweep=%lu, n_therm=%lu, n_run=%lu, step_size=%g",
381 (
unsigned long)n_sweep, (
unsigned long)n_therm, (
unsigned long)n_run, (
double)step_size);
385 inline CountIntType
n_sweep()
const {
return _n_sweep; }
387 inline CountIntType
n_therm()
const {
return _n_therm; }
389 inline CountIntType
n_run()
const {
return _n_run; }
392 inline RealScalar
step_size()
const {
return _step_size; }
403 curpt = _mhwalker.startpoint();
404 curptval = tomo_internal::MHRandomWalk_helper_decide_jump<MHWalker,UseFnSyntaxType>::get_ptval(_mhwalker, curpt);
414 _mhwalker.thermalizing_done();
415 _stats.thermalizing_done();
455 curptval = tomo_internal::MHRandomWalk_helper_decide_jump<MHWalker,UseFnSyntaxType>::get_ptval(_mhwalker, curpt);
456 _logger.longdebug(
"MHRandomWalk",
457 streamstr(
"set_curpt(): set internal state. Value = "<<curptval<<
"; Point =\n"<<pt<<
"\n"));
468 inline void move(CountIntType k,
bool is_thermalizing,
bool is_live_iter)
474 PointType newpt = _mhwalker.jump_fn(curpt, _step_size);
476 FnValueType newptval;
478 newptval = tomo_internal::MHRandomWalk_helper_decide_jump<MHWalker,UseFnSyntaxType>::get_ptval(_mhwalker, newpt);
480 double a = tomo_internal::MHRandomWalk_helper_decide_jump<MHWalker,UseFnSyntaxType>::get_a_value(
481 _mhwalker, newpt, newptval, curpt, curptval
487 accept = bool( _rng()-_rng.min() <= a*(_rng.max()-_rng.min()) );
491 if (!is_thermalizing) {
492 num_accepted += accept ? 1 : 0;
496 _stats.raw_move(k, is_thermalizing, is_live_iter, accept, a, newpt, newptval, curpt, curptval, *
this);
498 _logger.longdebug(
"MHRandomWalk",
499 "%s%3lu: %s a=%-7.2g, newptval=%5.4g [llh=%.4g], curptval=%5.4g [llh=%.4g] accept_ratio=%s",
500 (is_thermalizing?
"T":
"#"),
501 (
unsigned long)k, accept?
"AC":
"RJ", (
double)a, (
double)newptval, -2.0*newptval,
502 (
double)curptval, -2.0*curptval,
517 return (num_live_points > 0);
521 template<
typename RatioType =
double>
524 return (RatioType) num_accepted / num_live_points;
533 _stats.process_sample(k, n, curpt, curptval, *
this);
582 template<
typename... MHRWStatsCollectors>
590 static constexpr
int NumStatColl =
sizeof...(MHRWStatsCollectors);
598 : statscollectors(statscollectors_...)
604 inline const typename std::tuple_element<I, MHRWStatsCollectorsTupleType>::type & getStatsCollector()
606 return std::get<I>(statscollectors);
614 std::get<I>(statscollectors).init();
627 std::get<I>(statscollectors).thermalizing_done();
628 thermalizing_done<I+1>();
640 std::get<I>(statscollectors).done();
651 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk,
int I = 0>
653 CountIntType k,
bool is_thermalizing,
bool is_live_iter,
bool accepted,
654 double a,
const PointType & newpt, FnValueType newptval,
655 const PointType & curpt, FnValueType curptval,
659 std::get<I>(statscollectors).raw_move(
660 k, is_thermalizing, is_live_iter, accepted, a,
661 newpt, newptval, curpt, curptval, rw
663 raw_move<CountIntType, PointType, FnValueType, MHRandomWalk, I+1>(
664 k, is_thermalizing, is_live_iter, accepted, a,
665 newpt, newptval, curpt, curptval, rw
668 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk,
int I = 0>
670 CountIntType,
bool,
bool,
bool,
double,
const PointType &, FnValueType,
671 const PointType &, FnValueType, MHRandomWalk &
679 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk,
int I = 0>
681 CountIntType k, CountIntType n,
const PointType & curpt, FnValueType curptval, MHRandomWalk & rw
684 std::get<I>(statscollectors).process_sample(k, n, curpt, curptval, rw);
685 process_sample<CountIntType, PointType, FnValueType, MHRandomWalk, I+1>(k, n, curpt, curptval, rw);
688 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk,
int I = 0>
690 CountIntType, CountIntType,
const PointType &, FnValueType, MHRandomWalk &
716 template<
typename ValueCalculator_,
717 typename LoggerType = Logger::VacuumLogger,
718 typename HistogramType_ = UniformBinsHistogram<typename ValueCalculator_::ValueType>
743 HistogramType _histogram;
749 ValueCalculator _vcalc;
751 LoggerType & _logger;
756 const ValueCalculator & vcalc,
758 : _histogram(histogram_params),
797 template<
bool Pr
intHistogram = true>
800 if (PrintHistogram) {
803 _logger.longdebug(
"ValueHistogramMHRWStatsCollector",
804 "Done walking & collecting stats. Here's the histogram:\n"
805 + _histogram.pretty_print());
811 template<
typename CountIntType,
typename Po
intType,
typename LLHValueType,
typename MHRandomWalk>
813 double ,
const PointType & , LLHValueType ,
816 _logger.longdebug(
"ValueHistogramMHRWStatsCollector",
"raw_move(): k=%lu", (
unsigned long)k);
820 template<
typename CountIntType,
typename Po
intType,
typename LLHValueType,
typename MHRandomWalk>
824 ValueType val = _vcalc.getValue(curpt);
826 _logger.longdebug(
"ValueHistogramMHRWStatsCollector",
"in process_sample(): k=%lu, n=%lu, val=%.4g",
827 (
unsigned long)k, (
unsigned long)n, val);
829 return _histogram.record(val);
846 template<
typename ValueCalculator_,
847 typename CountIntType_ = int,
848 typename CountRealAvgType_ = double,
849 int NumTrackValues_ = Eigen::Dynamic,
850 int NumLevels_ = Eigen::Dynamic
899 template<
typename BinningAnalysisType>
900 Result(HistogramParams p,
const BinningAnalysisType & b)
903 converged_status(
Eigen::ArrayXi::Constant(b.num_track_values(), BinningAnalysisType::UNKNOWN_CONVERGENCE))
920 for (
int k = 0; k < converged_status.size(); ++k) {
921 str <<
"\tval[" <<
std::setw(3) << k <<
"] = "
925 str <<
" [CONVERGED]";
927 str <<
" [NOT CONVERGED]";
956 template<
typename Params,
957 typename LoggerType_ = Logger::VacuumLogger
1007 BinningAnalysisType binning_analysis;
1009 LoggerType & logger;
1016 const ValueCalculator & vcalc,
1018 LoggerType & logger_)
1019 : value_histogram(histogram_params, vcalc, logger_),
1020 binning_analysis(histogram_params.num_bins, num_levels, logger_),
1022 result(histogram_params, binning_analysis)
1024 logger.longdebug(
"ValueHistogramWithBinningMHRWStatsCollector",
"constructor()");
1033 inline const BinningAnalysisType & get_binning_analysis()
const
1035 return binning_analysis;
1054 value_histogram.
init();
1064 logger.longdebug(
"ValueHistogramWithBinningMHRWStatsCollector::done()",
"finishing up ...");
1066 value_histogram.template done<false>();
1068 const BaseHistogramType & h = value_histogram.
histogram();
1069 result.hist.params = h.params;
1070 CountRealAvgType normalization = h.bins.sum() + h.off_chart;
1072 result.hist.bins = h.bins.template cast<CountRealAvgType>() / normalization;
1074 result.hist.delta = result.error_levels.col(binning_analysis.
num_levels()).
template cast<CountRealAvgType>();
1075 result.hist.off_chart = h.off_chart / normalization;
1079 logger.debug(
"ValueHistogramWithBinningMHRWStatsCollector", [&,
this](
std::ostream & str) {
1080 str <<
"Binning analysis: bin sqmeans at different binning levels are:\n"
1082 <<
"\t-> so the error bars at different binning levels are:\n"
1083 << result.error_levels <<
"\n"
1084 <<
"\t-> convergence analysis: \n";
1085 result.dump_convergence_analysis(str);
1086 str <<
"\t... and just for you, here is the final histogram:\n" << result.hist.pretty_print() <<
"\n";
1091 template<
typename CountIntType2,
typename Po
intType,
typename LLHValueType,
typename MHRandomWalk>
1092 inline void raw_move(CountIntType2 k,
bool is_thermalizing,
bool is_live_iter,
bool accepted,
1093 double a,
const PointType & newpt, LLHValueType newptval,
1094 const PointType & curpt, LLHValueType curptval,
MHRandomWalk & mh)
1096 value_histogram.
raw_move(k, is_thermalizing, is_live_iter, accepted, a, newpt, newptval, curpt, curptval, mh);
1100 template<
typename CountIntType2,
typename Po
intType,
typename LLHValueType,
typename MHRandomWalk>
1101 inline void process_sample(CountIntType2 k, CountIntType2 n,
const PointType & curpt,
1123 template<
typename MHRWStatsCollector_>
1126 typedef MHRWStatsCollector_ MHRWStatsCollector;
1128 static constexpr
bool CanProvideStatus =
false;
1145 template<
typename... Args>
1150 static constexpr
int NumStatColl = MHRWStatsCollector::NumStatColl;
1152 static constexpr
bool CanProvideStatus =
true;
1154 template<int I = 0, typename std::enable_if<(I < NumStatColl), bool>::type dummy =
true>
1157 typedef typename std::tuple_element<I, typename MHRWStatsCollector::MHRWStatsCollectorsTupleType>::type
1164 + getStatus<I+1>(stats);
1167 template<int I = 0, typename std::enable_if<(I == NumStatColl), bool>::type dummy =
true>
1181 template<
typename ValueCalculator_,
1182 typename LoggerType_,
1183 typename HistogramType_
1189 static constexpr
bool CanProvideStatus =
true;
1193 const int maxbarwidth = 50;
1197 return "Histogram: " + histogram_short_bar<HistogramType>(stats->
histogram(),
true, maxbarwidth);
1204 template<
typename Params_,
1205 typename LoggerType_
1211 static constexpr
bool CanProvideStatus =
true;
1215 const int maxbarwidth = 50;
1218 const BaseHistogramType & histogram = stats->
histogram();
1223 typedef typename BinningAnalysisType::ValueType ValueType;
1224 const auto& binning_analysis = stats->get_binning_analysis();
1226 binmeans = histogram.bins.template cast<ValueType>() /
1227 (ValueType)(histogram.bins.sum() + histogram.off_chart);
1229 auto error_levels = binning_analysis.calc_error_levels(binmeans);
1230 auto conv_status = binning_analysis.determine_error_convergence(error_levels);
1236 if (conv_status(k) == BinningAnalysisType::CONVERGED) {
1238 }
else if (conv_status(k) == BinningAnalysisType::NOT_CONVERGED) {
1245 return tomo_internal::histogram_short_bar_fmt<BaseHistogramType>(histogram,
"", maxbarwidth)
1246 +
Tools::fmts(
" err: (cnvg/?/fail) %d/%d/%d", n_cnvg, n_unknown, n_not_cnvg);
A StatsCollector which builds a histogram of values calculated with a ValueCalculator for each data s...
A Metropolis-Hastings Random Walk.
Eigen::ArrayXi determine_error_convergence(const Eigen::Ref< const BinSumSqArray > &error_levels) const
Attempt to determine if the error bars have converged.
Result type of the corresponding ValueHistogramWithBinningMHRWStatsCollector.
Params::BaseHistogramType BaseHistogramType
See ValueHistogramWithBinningMHRWStatsCollectorParams::BaseHistogramType .
MHWalker::PointType PointType
The type of a point in the random walk.
void process_sample(CountIntType2 k, CountIntType2 n, const PointType &curpt, LLHValueType curptval, MHRandomWalk &mh)
Part of the MHRWStatsCollector Interface. Records the sample in the histogram.
const Result & getResult() const
Get the final histogram data. This method is needed for Resultable Interface compliance.
Result(HistogramParams p, const BinningAnalysisType &b)
Constructor which initializes the fields from the histogram and binning analysis type.
void done()
Finalize the data collection. Part of the MHRWStatsCollector Interface.
BinningAnalysis< BinningAnalysisParamsType, LoggerType > BinningAnalysisType
See ValueHistogramWithBinningMHRWStatsCollectorParams::BinningAnalysisType .
void done()
Part of the MHRWStatsCollector Interface.
Base namespace for the Tomographer project.
CountRealAvgType_ CountRealAvgType
Type used to store the averages of the histogram bins.
std::size_t process_sample(CountIntType k, CountIntType n, const PointType &curpt, LLHValueType, MHRandomWalk &)
Part of the MHRWStatsCollector Interface. Records the sample in the histogram.
ValueHistogramMHRWStatsCollector(HistogramParams histogram_params, const ValueCalculator &vcalc, LoggerType &logger)
Simple constructor, initializes with the given values.
void init()
Required for RandomWalk Interface. Resets counts and relays to the MHWalker and the MHRWStatsCollecto...
ValueCalculator::ValueType ValueType
The type to use to represent a calculated distance.
Eigen::ArrayXi converged_status
Information of convergence status of the error bars (see e.g. BinningAnalysisParamsType::CONVERGED) ...
void thermalizing_done()
Part of the MHRWStatsCollector Interface. No-op.
Group template parameters for BinningAnalysis.
RealScalar step_size() const
Get the step size of the random walk.
BinSumSqArray calc_error_levels(const Eigen::ArrayBase< Derived > &means) const
Calculate the error bars of samples at different binning levels.
MHRWStatsCollector_ MHRWStatsCollector
The stats collector type (see MHRWStatsCollector Interface)
The error bars appear to have converged.
CountIntType n_run() const
Required for RandomWalk Interface. Number of live run sweeps.
Params::HistogramParams HistogramParams
See ValueHistogramWithBinningMHRWStatsCollectorParams::HistogramParams .
void dump_convergence_analysis(std::ostream &str) const
Dump values, error bars and convergence status in human-readable form into ostream.
ValueCalculator_ ValueCalculator
The type which calculates the interesting value. Should be of type interface ValueCalculator Interfac...
HistogramType hist
Histogram, already with error bars.
Unable to determine whether the error bars have converged.
void thermalizing_done()
Required for RandomWalk Interface. Relays to the MHWalker and the MHRWStatsCollector.
MHWalker_ MHWalker
The random walker type which knows about the state space and jump function.
UniformBinsHistogram< typename ValueCalculator::ValueType, CountIntType > BaseHistogramType
The Base Histogram Type.
Result()
Simple default constructor (e.g. to use as std::vector).
HistogramType::Params HistogramParams
Structure which holds the parameters of the histogram we're recording.
The error bars don't seem to have converged.
Define types for quantum objects. See Tomographer::MatrQ.
Params::Result Result
See ValueHistogramWithBinningMHRWStatsCollectorParams::Result .
_FnValueType FnValueType
The type of the Metropolis-Hastings function value. (See class documentation)
auto can_basis_vec(IndexType k, IndexType size) -> const Eigen::CwiseNullaryOp< tomo_internal::can_basis_vec_generator< typename Eigen::internal::traits< Der >::Scalar, IndexType >, Der >
Expression for the k-th canonical basis vector of given dimension.
static constexpr int NumStatColl
The number of stats collectors we are tracking.
void set_curpt(const PointType &pt)
Force manual state of random walk.
BinningAnalysisParamsType::BinSumSqArray error_levels
Detailed error bars for all binning levels.
Provides the MH function value at each point (see Role of UseFnSyntaxType)
Traits-like class for ValueHistogramWithBinningMHRWStatsCollector.
const Tools::static_or_dynamic< int, NumLevelsCTime > num_levels
The number of levels in the binning analysis.
Collect a histogram of values from a MH random walk, with binning analysis.
LoggerType_ LoggerType
The logger type (see Logging and Loggers)
void done()
Required for RandomWalk Interface. Relays to the MHWalker and the MHRWStatsCollector.
Data corresponding to a quantum tomography setting.
Tools for parameterizing hermitian matrices with the X Parameterization.
Params::ValueType ValueType
See ValueHistogramWithBinningMHRWStatsCollectorParams::ValueType .
CountIntType n_sweep() const
Required for RandomWalk Interface. Number of iterations in a sweep.
const HistogramType & histogram() const
Get the histogram data collected so far. See HistogramType.
Params::BinningAnalysisParamsType BinningAnalysisParamsType
See ValueHistogramWithBinningMHRWStatsCollectorParams::BinningAnalysisParamsType .
Params::ValueCalculator ValueCalculator
See ValueHistogramWithBinningMHRWStatsCollectorParams::ValueCalculator .
Provides directly the ratio of the function values for two consecutive points of the MH random walk (...
bool has_acceptance_ratio() const
Query whether we have any statistics about acceptance ratio. This is false, for example, during the thermalizing runs.
void raw_move(CountIntType2 k, bool is_thermalizing, bool is_live_iter, bool accepted, double a, const PointType &newpt, LLHValueType newptval, const PointType &curpt, LLHValueType curptval, MHRandomWalk &mh)
Part of the MHRWStatsCollector Interface. No-op.
Params::CountRealAvgType CountRealAvgType
See ValueHistogramWithBinningMHRWStatsCollectorParams::CountRealAvgType .
Rng_ Rng
Random number generator type (see C++ std::random)
static void run(RandomWalk &rw)
Run the random walk. (pun intended)
HistogramType_ HistogramType
The type of the histogram. Usually a UniformBinsHistogram with ValueType range type.
static std::string getStatus(const MHRWStatsCollector *)
Prepare a string which reports the status of the given stats collector.
static constexpr int NumTrackValuesCTime
See ValueHistogramWithBinningMHRWStatsCollectorParams::NumTrackValues .
void init()
Part of the MHRWStatsCollector Interface. Initializes the histogram to zeros.
void process_sample(CountIntType k, CountIntType n)
Required for RandomWalk Interface. Process a new live sample in the random walk. Relays the call to t...
Provides the logarithm MH function value at each point (see Role of UseFnSyntaxType) ...
Base_::Params Params
Shortcut for our base class' histogram parameters. See UniformBinsHistogram
Template, specializable class to get status reports from stats collectors.
void raw_move(CountIntType k, bool, bool, bool, double, const PointType &, LLHValueType, const PointType &, LLHValueType, MHRandomWalk &)
Part of the MHRWStatsCollector Interface. No-op.
Params::CountIntType CountIntType
See ValueHistogramWithBinningMHRWStatsCollectorParams::CountIntType .
BinningAnalysisParams< ValueType, NumTrackValues, NumLevels, false, CountIntType > BinningAnalysisParamsType
The relevant BinningAnalysis parameters for us.
std::string dump_convergence_analysis() const
Dump values, error bars and convergence status in human-readable form as string.
ValueCalculator_ ValueCalculator
The type of the ValueCalculator Interface which calculates the value of which we're collecting a hist...
LoggerType_ LoggerType
Somewhere where this object may log what it's doing.
void process_new_values(const Eigen::DenseBase< Derived > &vals)
Process new raw samples.
const Result & getResult() const
Get the histogram data collected so far. This method is needed for Resultable Interface compliance...
Definitions for Histogram Types.
UniformBinsHistogramWithErrorBars< typename ValueCalculator::ValueType, CountRealAvgType > HistogramType
The Final Histogram Type (with error bars).
Long Debug logging level.
MHWalker::RealScalar RealScalar
The type of a step size of the random walk.
#define streamstr(tokens)
Utility macro to format stream tokens to a std::string.
static constexpr int NumLevels
The number of levels in the binning analysis. See BinningAnalysis.
static constexpr int NumTrackValues
Number of values we're tracking, i.e. the number of bins in the histogram [for now].
MHRandomWalk(CountIntType n_sweep, CountIntType n_therm, CountIntType n_run, RealScalar step_size, MHWalker &mhwalker, MHRWStatsCollector &stats, Rng &rng, LoggerType &logger_)
Simple constructor, initializes the given fields.
const FnValueType & get_curptval() const
Access the current function value of the random walk.
CountIntType_ CountIntType
The type used for counting numbers of iterations (see, e.g. n_sweep())
void move(CountIntType k, bool is_thermalizing, bool is_live_iter)
Required for RandomWalk Interface. Processes a single move in the random walk.
Binning Analysis in a Metropolis-Hastings random walk.
static constexpr int NumLevelsCTime
See ValueHistogramWithBinningMHRWStatsCollectorParams::NumLevels .
void init()
Part of the MHRWStatsCollector Interface. Initializes the histogram to zeros.
const BaseHistogramType & histogram() const
Get the histogram data collected so far. See BaseHistogramType .
Basic utilities for dealing with Eigen matrices and other types.
CountIntType n_therm() const
Required for RandomWalk Interface. Number of thermalizing sweeps.
HistogramType_ Result
Required for compliance with Resultable Interface type.
ValueHistogramMHRWStatsCollector< ValueCalculator, LoggerType, BaseHistogramType > ValueHistogramMHRWStatsCollectorType
This is the natural ValueHistogramMHRWStatsCollector type on which we're adding error bars...
const PointType & get_curpt() const
Access the current state of the random walk.
RatioType acceptance_ratio() const
Return the acceptance ratio so far.
Utilities for logging messages.
ValueCalculator::ValueType ValueType
The type of a value calculated by the ValueCalculator Interface.
A simple MHRWStatsCollector interface which combines several stats collectors.
Base class performing an abstract random walk.
auto get_bin_sqmeans() const
Get the raw average of the squared values observed, for each binning level.
How to calculate the Metropolis-Hastings jump probability ratio (see class documentation) ...
CountIntType_ CountIntType
Type used to count the number of hits in each bin.
void thermalizing_done()
Part of the MHRWStatsCollector Interface. No-op.