28 #ifndef TOMOGRAPHER_MHRWSTATSCOLLECTORS_H 29 #define TOMOGRAPHER_MHRWSTATSCOLLECTORS_H 36 #include <type_traits> 42 #include <tomographer/tools/statusprovider.h> 65 namespace tomo_internal {
67 typedef MHRWStatsCollectorNoResult NoResult;
69 template<
typename MHRWStatsCollector,
typename dummy =
void>
70 struct multistatscoll_result_type_helper {
72 typedef NoResult ResultType;
73 static inline ResultType getResult(
const MHRWStatsCollector & ) {
return NoResult(); }
74 static inline ResultType stealResult(MHRWStatsCollector & ) {
return NoResult(); }
76 template<
typename MHRWStatsCollector>
77 struct multistatscoll_result_type_helper<
80 typename std::enable_if<
81 !std::is_same<typename MHRWStatsCollector::ResultType,void>::value,
87 typedef typename MHRWStatsCollector::ResultType ResultType;
88 static inline ResultType getResult(
const MHRWStatsCollector & s) {
return s.getResult(); }
89 static inline ResultType stealResult(MHRWStatsCollector & s) {
return s.stealResult(); }
92 template<
typename ResultType,
typename... MHRWStatsCollectors>
93 struct multistatscoll_result_type_helper2 {
94 typedef std::tuple<MHRWStatsCollectors&...> TupleRefType;
95 typedef std::tuple<MHRWStatsCollectors...> TupleType;
96 template<
typename T,
int... Is>
100 multistatscoll_result_type_helper<
typename std::tuple_element<Is, TupleType>::type>::getResult(
101 std::get<Is>(statscollectors)
105 template<
typename T,
int... Is>
110 multistatscoll_result_type_helper<
typename std::tuple_element<Is, TupleType>::type>::stealResult(
111 std::get<Is>(statscollectors)
156 template<
typename... MHRWStatsCollectors>
164 static constexpr
int NumStatColl =
sizeof...(MHRWStatsCollectors);
172 : statscollectors(statscollectors_...)
181 inline const typename std::tuple_element<I, MHRWStatsCollectorsTupleType>::type & getStatsCollector()
const 183 return std::get<I>(statscollectors);
191 return tomo_internal::multistatscoll_result_type_helper2<ResultType, MHRWStatsCollectors...>::getResult(
198 return tomo_internal::multistatscoll_result_type_helper2<ResultType, MHRWStatsCollectors...>::stealResult(
210 std::get<I>(statscollectors).init();
223 std::get<I>(statscollectors).thermalizingDone();
224 thermalizingDone<I+1>();
236 std::get<I>(statscollectors).done();
247 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk,
int I = 0>
249 CountIntType k,
bool is_thermalizing,
bool is_live_iter,
bool accepted,
250 double a,
const PointType & newpt, FnValueType newptval,
251 const PointType & curpt, FnValueType curptval,
255 std::get<I>(statscollectors).rawMove(
256 k, is_thermalizing, is_live_iter, accepted, a,
257 newpt, newptval, curpt, curptval, rw
259 rawMove<CountIntType, PointType, FnValueType, MHRandomWalk, I+1>(
260 k, is_thermalizing, is_live_iter, accepted, a,
261 newpt, newptval, curpt, curptval, rw
264 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk,
int I = 0>
266 CountIntType,
bool,
bool,
bool,
double,
const PointType &, FnValueType,
275 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk,
int I = 0>
277 CountIntType k, CountIntType n,
const PointType & curpt, FnValueType curptval,
MHRandomWalk & rw
280 std::get<I>(statscollectors).processSample(k, n, curpt, curptval, rw);
281 processSample<CountIntType, PointType, FnValueType, MHRandomWalk, I+1>(k, n, curpt, curptval, rw);
284 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk,
int I = 0>
286 CountIntType, CountIntType,
const PointType &, FnValueType,
MHRandomWalk &
308 template<
typename... MHRWStatsCollectors>
326 template<
typename IterCountIntType_ =
int>
330 typedef IterCountIntType_ IterCountIntType;
333 Eigen::ArrayXi accept_buffer;
334 IterCountIntType pos;
339 : accept_buffer(Eigen::ArrayXi::Zero(num_samples_)), pos(0)
343 inline Eigen::Index bufferSize()
const {
344 return accept_buffer.size();
349 return (
double)accept_buffer.count() / accept_buffer.size();
354 return ( pos >= accept_buffer.size() );
365 inline void thermalizingDone()
377 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename Po
intType2,
typename MHRandomWalk>
379 CountIntType ,
bool ,
bool ,
bool accepted,
380 double , PointType && , FnValueType ,
381 PointType2 && , FnValueType ,
388 accept_buffer[ pos % accept_buffer.size() ] = (int)accepted;
395 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk>
396 inline void processSample(
397 CountIntType , CountIntType , PointType && , FnValueType ,
MHRandomWalk &&
425 template<
typename ValueCalculator_,
453 HistogramType _histogram;
459 ValueCalculator _vcalc;
461 LoggerType & _logger;
466 const ValueCalculator & vcalc,
468 : _histogram(histogram_params),
525 template<
bool Pr
intHistogram = true>
528 if (PrintHistogram) {
531 _logger.longdebug(
"ValueHistogramMHRWStatsCollector",
532 "Done walking & collecting stats. Here's the histogram:\n" 533 + _histogram.prettyPrint());
539 template<
typename CountIntType,
typename Po
intType,
typename LLHValueType,
typename MHRandomWalk>
540 void rawMove(CountIntType k,
bool ,
bool ,
bool ,
541 double ,
const PointType & , LLHValueType ,
544 _logger.longdebug(
"ValueHistogramMHRWStatsCollector", [&](
std::ostream & stream) {
545 stream <<
"rawMove(): k=" << k;
550 template<
typename CountIntType,
typename Po
intType,
typename LLHValueType,
typename MHRandomWalk>
551 Eigen::Index
processSample(CountIntType k, CountIntType n,
const PointType & curpt,
554 ValueType val = _vcalc.getValue(curpt);
556 _logger.longdebug(
"ValueHistogramMHRWStatsCollector", [&](
std::ostream & stream) {
557 stream <<
"in processSample(): " 558 <<
"k=" << k <<
", n=" << n <<
", val=" << val
559 <<
" [with ValueType=" <<
typeid(ValueType).name() <<
"]" ;
562 return _histogram.record(val);
578 template<
typename HistogramType_,
typename BinningAnalysisParamsType_>
582 typename BinningAnalysisParamsType_::BinSumSqArray
585 typedef HistogramType_ HistogramType;
586 typedef typename HistogramType::Params HistogramParams;
587 typedef BinningAnalysisParamsType_ BinningAnalysisParamsType;
591 : histogram(), error_levels(), converged_status()
603 : histogram(HistogramType::copy(copy.
histogram)),
610 template<
typename EigenDerived1,
typename EigenDerived2>
614 : histogram(HistogramType::copy(histogram_)),
615 error_levels(error_levels_),
616 converged_status(converged_status_)
621 template<
typename BinningAnalysisType>
624 error_levels(b.numTrackValues(), b.numLevels()+1),
625 converged_status(
Eigen::ArrayXi::Constant(b.numTrackValues(), BinningAnalysisType::UNKNOWN_CONVERGENCE))
627 tomographer_assert(converged_status.rows() == b.numTrackValues() && converged_status.cols() == 1);
660 for (
int k = 0; k < converged_status.size(); ++k) {
661 stream <<
"\tval[" <<
std::setw(3) << k <<
"] = " 663 <<
" +- " <<
std::setw(12) << histogram.delta(k);
665 stream <<
" [CONVERGED]";
667 stream <<
" [NOT CONVERGED]";
669 stream <<
" [UNKNOWN]";
671 stream <<
" [INVALID CONVERGENCE STATUS: " << converged_status(k) <<
"]";
681 dumpConvergenceAnalysis(ss);
697 template<
typename ValueCalculator_,
698 typename CountIntType_ = int,
699 typename CountRealAvgType_ = double,
700 int NumTrackValues_ = Eigen::Dynamic,
701 int NumLevels_ = Eigen::Dynamic
714 static constexpr
int NumTrackValues = NumTrackValues_;
716 static constexpr
int NumLevels = NumLevels_;
752 template<
typename Params,
757 typename Params::ValueCalculator,
759 typename Params::BaseHistogramType
761 BinningAnalysis<typename Params::BinningAnalysisParamsType, LoggerType_>,
762 typename Params::Result
791 static constexpr
int NumTrackValuesCTime = Params::NumTrackValues;
793 static constexpr
int NumLevelsCTime = Params::NumLevels;
811 BinningAnalysisType binning_analysis;
820 const ValueCalculator & vcalc,
822 LoggerType & logger_)
823 : value_histogram(histogram_params, vcalc, logger_),
824 binning_analysis((int)histogram_params.num_bins, num_levels, logger_),
826 result(histogram_params, binning_analysis)
828 logger.longdebug(
"ValueHistogramWithBinningMHRWStatsCollector",
"constructor()");
837 inline const BinningAnalysisType & getBinningAnalysis()
const 839 return binning_analysis;
858 const BaseHistogramType & hist = histogram();
859 return hist.bins.template cast<CountRealAvgType>() /
860 (CountRealAvgType)(hist.bins.sum() + hist.off_chart);
883 value_histogram.
init();
893 logger.longdebug(
"ValueHistogramWithBinningMHRWStatsCollector::done()",
"finishing up ...");
895 value_histogram.template done<false>();
906 const BaseHistogramType & h = value_histogram.
histogram();
907 result.histogram.params = h.params;
908 CountRealAvgType numsamples = h.bins.sum() + h.off_chart;
909 result.histogram.bins = h.bins.template cast<CountRealAvgType>() / numsamples;
910 result.error_levels = binning_analysis.
calcErrorLevels(result.histogram.bins);
911 result.histogram.delta = result.error_levels.col(binning_analysis.
numLevels()).
template cast<CountRealAvgType>();
912 result.histogram.off_chart = h.off_chart / numsamples;
916 logger.debug(
"ValueHistogramWithBinningMHRWStatsCollector", [&,
this](
std::ostream & str) {
917 str <<
"Binning analysis: bin sqmeans at different binning levels are:\n" 919 <<
"\t-> so the error bars at different binning levels are:\n" 920 << result.error_levels <<
"\n" 921 <<
"\t-> convergence analysis: \n";
922 result.dumpConvergenceAnalysis(str);
923 str <<
"\t... and just for you, here is the final histogram:\n" << result.histogram.prettyPrint() <<
"\n";
928 template<
typename CountIntType2,
typename Po
intType,
typename LLHValueType,
typename MHRandomWalk>
929 inline void rawMove(CountIntType2 k,
bool is_thermalizing,
bool is_live_iter,
bool accepted,
930 double a,
const PointType & newpt, LLHValueType newptval,
931 const PointType & curpt, LLHValueType curptval,
MHRandomWalk & mh)
933 value_histogram.
rawMove(k, is_thermalizing, is_live_iter, accepted, a, newpt, newptval, curpt, curptval, mh);
937 template<
typename CountIntType2,
typename Po
intType,
typename LLHValueType,
typename MHRandomWalk>
938 inline void processSample(CountIntType2 k, CountIntType2 n,
const PointType & curpt,
941 Eigen::Index histindex = value_histogram.
processSample(k, n, curpt, curptval, mh);
961 typename HistogramType_::Params hist_params,
962 ValueCalculator_ valcalc,
977 template<
typename ValueCalculator_,
typename CountIntType_ = int,
978 typename CountRealAvgType_ = double,
int NumTrackValues_ = Eigen::Dynamic,
979 int NumLevels_ = Eigen::Dynamic,
984 CountRealAvgType_, NumTrackValues_,
990 ValueCalculator_ valcalc,
991 int num_binning_levels,
998 CountRealAvgType_, NumTrackValues_,
1009 template<
typename MHRWParamsType_>
1013 typedef MHRWParamsType_ MHRWParamsType;
1021 template<
typename PredicateFn,
typename SendStatusFn>
1023 : pred_fn(pred_fn_), send_status_fn(send_status_fn_)
1026 inline void init() { }
1027 inline void thermalizingDone() { }
1028 inline void done() { }
1030 template<
typename IterCountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk>
1031 inline void rawMove(
1032 IterCountIntType k,
bool is_thermalizing,
bool,
bool,
double,
const PointType &, FnValueType,
1039 if ((k % rw.
nSweep() == 0) && pred_fn()) {
1041 MHRWStatusReportType::createFromRandWalkStatInfo(k, is_thermalizing, rw,
1049 template<
typename IterCountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk>
1050 inline void processSample(IterCountIntType, IterCountIntType, PointType&&, FnValueType,
MHRandomWalk &)
1059 template<
typename MHRWParamsType_,
typename ClockType_ =
1061 #if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 6 && !defined(__clang__) 1062 std::chrono::monotonic_clock
1070 typedef MHRWParamsType_ MHRWParamsType;
1073 typedef ClockType_ ClockType;
1074 typedef typename ClockType::time_point TimePoint;
1075 typedef typename ClockType::duration DurationType;
1078 TimePoint last_status_report;
1079 DurationType interval;
1083 template<
typename DurationInit,
typename SendStatusFn>
1085 : interval(interval_), send_status_fn(send_status_fn_)
1088 inline void init() { }
1089 inline void thermalizingDone() { }
1090 inline void done() { }
1092 template<
typename IterCountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk>
1093 inline void rawMove(
1094 IterCountIntType k,
bool is_thermalizing,
bool,
bool,
double,
const PointType &, FnValueType,
1099 if ((k % rw.
nSweep() == 0)) {
1101 auto now = ClockType::now();
1103 if ( interval.count() > 0 && (now - (last_status_report + interval)).count() > 0 ) {
1106 MHRWStatusReportType::createFromRandWalkStatInfo(k, is_thermalizing, rw,
1110 last_status_report = now;
1117 template<
typename IterCountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk>
1118 inline void processSample(IterCountIntType, IterCountIntType, PointType&&, FnValueType,
MHRandomWalk &)
1141 template<
typename... Args>
1147 static constexpr
int NumStatColl = MHRWStatsCollector::NumStatColl;
1149 static constexpr
bool CanProvideStatusLine =
true;
1151 template<int I = 0, typename std::enable_if<(I < NumStatColl), bool>::type dummy =
true>
1154 typedef typename std::tuple_element<I, typename MHRWStatsCollector::MHRWStatsCollectorsTupleType>::type
1160 getStatusLine<I+1>(stats) );
1163 template<int I = 0, typename std::enable_if<(I == NumStatColl), bool>::type dummy =
true>
1179 template<
typename... Args>
1181 template<
typename... Args>
1189 template<
typename ValueCalculator_,
1190 typename LoggerType_,
1191 typename HistogramType_
1197 static constexpr
bool CanProvideStatusLine =
true;
1199 static inline std::string getStatusLine(
const MHRWStatsCollector * stats)
1201 const int maxbarwidth = 50;
1205 return "Histogram: " + histogramShortBar<HistogramType>(stats->
histogram(),
true, maxbarwidth);
1209 template<
typename ValueCalculator_,
1210 typename LoggerType_,
1211 typename HistogramType_
1220 template<
typename Params_,
1221 typename LoggerType_
1227 static constexpr
bool CanProvideStatusLine =
true;
1229 static inline std::string getStatusLine(
const MHRWStatsCollector * stats)
1231 const int maxbarwidth = 50;
1234 const BaseHistogramType & histogram = stats->
histogram();
1240 const auto& binning_analysis = stats->getBinningAnalysis();
1241 const auto binmeans = stats->
binMeans();
1243 auto error_levels = binning_analysis.calcErrorLevels(binmeans);
1244 auto conv_status = binning_analysis.determineErrorConvergence(error_levels);
1248 return histogramShortBar<BaseHistogramType>(histogram,
true, maxbarwidth)
1250 (
int)conv_summary.n_converged, (int)conv_summary.n_unknown,
1251 (
int)conv_summary.n_not_converged);
1255 template<
typename Params_,
1256 typename LoggerType_
1265 template<
typename CountIntType_>
1268 static constexpr
bool CanProvideStatusLine =
true;
1273 return Tools::fmts(
"acceptance ratio = %.2g (over last %d iter)",
1275 (int)obj->bufferSize());
A StatsCollector which builds a histogram of values calculated with a ValueCalculator for each data s...
A Metropolis-Hastings Random Walk.
HistogramType histogram
Histogram, already with error bars.
It is unknown whether the error bar has converged or not.
Eigen::Array< CountRealAvgType, Eigen::Dynamic, 1 > binMeans() const
Get the current bin means collected so far.
static BinningErrorBarConvergenceSummary fromConvergedStatus(const Eigen::Ref< const Eigen::ArrayXi > &converged_status)
Construct a summary object from a list of converged status obtained from BinningAnalysis::determineEr...
Params::BaseHistogramType BaseHistogramType
See ValueHistogramWithBinningMHRWStatsCollectorParams::BaseHistogramType .
const MHRWStatsCollector & statsCollector() const
Access the stats collector.
void done()
Finalize the data collection. Part of the MHRWStatsCollector Interface.
BinningAnalysis< BinningAnalysisParamsType, LoggerType > BinningAnalysisType
The corresponding BinningAnalysis type for this value histogram stats collector.
auto getBinSqmeans() const
Get the raw average of the squared values observed, for each binning level.
The parameters of a Histogram.
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.
ValueHistogramMHRWStatsCollector(HistogramParams histogram_params, const ValueCalculator &vcalc, LoggerType &logger)
Simple constructor, initializes with the given values.
const BaseHistogramType & histogram() const
Get the histogram data collected so far. See BaseHistogramType .
MultipleMHRWStatsCollectors< MHRWStatsCollectors... > mkMultipleMHRWStatsCollectors(MHRWStatsCollectors &... mhrwstatscollectors)
Convenience function to create a MultipleMHRWStatsCollector (using template argument deduction) ...
ValueCalculator::ValueType ValueType
The type to use to represent a calculated distance.
HistogramWithErrorBars< typename ValueCalculator::ValueType, CountRealAvgType > HistogramType
The Final Histogram Type (with error bars).
The error bar appears to have converged.
ValueHistogramMHRWStatsCollector< ValueCalculator_, LoggerType, HistogramType_ > mkValueHistogramMHRWStatsCollector(typename HistogramType_::Params hist_params, ValueCalculator_ valcalc, LoggerType &logger)
Helper to easily instantiate a ValueHistogramMHRWStatsCollector.
Eigen::ArrayXi converged_status
Information of convergence status of the error bars (see e.g. BINNING_CONVERGED)
Group template parameters for BinningAnalysis.
Eigen::ArrayXi determineErrorConvergence(const Eigen::Ref< const BinSumSqArray > &error_levels) const
Attempt to determine if the error bars have converged.
Result type of a ValueHistogramWithBinningMHRWStatsCollector.
HistogramType::Params HistogramParams
The corresponding histogram params type.
ValueHistogramWithBinningMHRWStatsCollectorResult(HistogramParams p, const BinningAnalysisType &b)
Constructor which initializes the fields from the histogram and binning analysis type.
Stores a histogram along with error bars.
Params::HistogramParams HistogramParams
See ValueHistogramWithBinningMHRWStatsCollectorParams::HistogramParams .
void processNewValues(const Eigen::DenseBase< Derived > &vals)
Process new raw samples.
ValueHistogramWithBinningMHRWStatsCollectorResult(const HistogramType &histogram_, const Eigen::DenseBase< EigenDerived1 > &error_levels_, const Eigen::DenseBase< EigenDerived2 > &converged_status_)
Simple constructor with direct initialization of fields.
ValueCalculator_ ValueCalculator
The type which calculates the interesting value. Should be of type interface ValueCalculator Interfac...
const Tools::StaticOrDynamic< int,(NumLevelsCTime==Eigen::Dynamic), NumLevelsCTime > numLevels
The number of levels in the binning analysis.
void thermalizingDone()
Part of the MHRWStatsCollector Interface. No-op.
Logger that discards all messages.
bool hasMovingAverageAcceptanceRatio() const
Returns true after enough samples have been collected to fill the internal buffer.
BinningErrorBarConvergenceSummary errorBarConvergenceSummary() const
A summary of the convergence status of the binning error bars.
void rawMove(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.
A "stats collector" which produces status reports whenever a predicate evaluates to true...
HistogramType::Params HistogramParams
Structure which holds the parameters of the histogram we're recording.
const MHRWController & mhrwController() const
Access the random walk controller.
HistogramType_ ResultType
Required for compliance with Resultable Interface type.
const ResultType & getResult() const
Get the histogram data collected. This method is needed for Resultable Interface compliance.
Traits-like class for ValueHistogramWithBinningMHRWStatsCollector.
double movingAverageAcceptanceRatio() const
Returns the average acceptance ratio as stored in the buffer.
An empty struct used as a ResultType in MultipleMHRWStatsCollector for stats collectors which don't r...
Collect a histogram of values from a MH random walk, with binning analysis.
BinSumSqArray calcErrorLevels(const Eigen::ArrayBase< Derived > &means) const
Calculate the error bars of samples at different binning levels.
const HistogramType & histogram() const
Get the histogram data collected so far. See HistogramType.
Params::ValueType ValueType
See ValueHistogramWithBinningMHRWStatsCollectorParams::ValueType .
Params::BinningAnalysisParamsType BinningAnalysisParamsType
See ValueHistogramWithBinningMHRWStatsCollectorParams::BinningAnalysisParamsType .
Params::ValueCalculator ValueCalculator
See ValueHistogramWithBinningMHRWStatsCollectorParams::ValueCalculator .
void thermalizingDone()
Part of the MHRWStatsCollector Interface. No-op.
void rawMove(CountIntType k, bool, bool, bool, double, const PointType &, LLHValueType, const PointType &, LLHValueType, MHRandomWalk &)
Part of the MHRWStatsCollector Interface. No-op.
ResultType stealResult()
Retrieve the collected histogram data, in compliance with Resultable Interface compliance.
ValueHistogramWithBinningMHRWStatsCollectorResult< HistogramType, BinningAnalysisParamsType > Result
Result type of the corresponding ValueHistogramWithBinningMHRWStatsCollector.
Params::CountRealAvgType CountRealAvgType
See ValueHistogramWithBinningMHRWStatsCollectorParams::CountRealAvgType .
A "stats collector" which produces status reports periodically.
Some C++ utilities, with a tad of C++11 tricks.
void dumpConvergenceAnalysis(std::ostream &stream) const
Dump values, error bars and convergence status in verbose, debug-human-readable form into ostream...
HistogramType_ HistogramType
The type of the histogram. Usually a Histogram with ValueType range type.
CountIntType nSweep() const
Number of iterations in a sweep.
The error bar appears NOT to have converged.
Status Report structure representing the status of a MHRandomWalk.
void init()
Part of the MHRWStatsCollector Interface. Initializes the histogram to zeros.
std::string dumpConvergenceAnalysis() const
Dump values, error bars and convergence status in verbose, debug-human-readable form as string...
Params::CountIntType CountIntType
See ValueHistogramWithBinningMHRWStatsCollectorParams::CountIntType .
BinningAnalysisParams< ValueType, NumTrackValues, NumLevels, false, CountIntType > BinningAnalysisParamsType
The relevant BinningAnalysis parameters for us.
Brief summary of convergence of error bars from a binning analysis.
ValueCalculator_ ValueCalculator
The type of the ValueCalculator Interface which calculates the value of which we're collecting a hist...
ResultType stealResult()
Retrieve the final histogram data, in compliance with Resultable Interface compliance.
void processSample(CountIntType2 k, CountIntType2 n, const PointType &curpt, LLHValueType curptval, MHRandomWalk &mh)
Part of the MHRWStatsCollector Interface. Records the sample in the histogram.
LoggerType_ LoggerType
Somewhere where this object may log what it's doing.
ValueHistogramWithBinningMHRWStatsCollectorResult()
Simple default constructor (e.g. to use as std::vector<Result>).
ValueHistogramWithBinningMHRWStatsCollector< ValueHistogramWithBinningMHRWStatsCollectorParams< ValueCalculator_, CountIntType_, CountRealAvgType_, NumTrackValues_, NumLevels_ >, LoggerType > mkValueHistogramWithBinningMHRWStatsCollector(HistogramParams< typename ValueCalculator_::ValueType > hist_params, ValueCalculator_ valcalc, int num_binning_levels, LoggerType &logger)
Helper to easily instantiate a ValueHistogramWithBinningMHRWStatsCollector.
Definitions for Histogram Types.
Long Debug logging level.
Histogram< typename ValueCalculator::ValueType, CountIntType > BaseHistogramType
The Base Histogram Type.
Params::Result ResultType
See ValueHistogramWithBinningMHRWStatsCollectorParams::Result .
Routines for performing a Metropolis-Hastings random walk.
Binning Analysis in a Metropolis-Hastings random walk.
void init()
Part of the MHRWStatsCollector Interface. Initializes the histogram to zeros.
const ResultType & getResult() const
Get the final histogram data. This method is needed for Resultable Interface compliance.
#define tomographer_assert(...)
Assertion test macro.
BinningAnalysisParamsType::BinSumSqArray error_levels
Detailed error bars for all binning levels.
ValueHistogramMHRWStatsCollector< ValueCalculator, LoggerType, BaseHistogramType > ValueHistogramMHRWStatsCollectorType
This is the natural ValueHistogramMHRWStatsCollector type on which we're adding error bars...
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.
Eigen::Index processSample(CountIntType k, CountIntType n, const PointType &curpt, LLHValueType, MHRandomWalk &)
Part of the MHRWStatsCollector Interface. Records the sample in the histogram.
MultipleMHRWStatsCollectors TrivialMHRWStatsCollector
Trivial, NO-OP stats collector.
CountIntType_ CountIntType
Type used to count the number of hits in each bin.