28 #ifndef TOMOGRAPHER_MHRWSTATSCOLLECTORS_H 29 #define TOMOGRAPHER_MHRWSTATSCOLLECTORS_H 36 #include <type_traits> 42 #include <tomographer/tools/statusprovider.h> 69 friend boost::serialization::access;
70 template<
typename Archive>
71 void serialize(Archive & ,
unsigned int ) { }
75 namespace tomo_internal {
79 template<
typename MHRWStatsCollector,
typename dummy =
void>
80 struct multistatscoll_result_type_helper {
82 typedef NoResult ResultType;
83 static inline ResultType getResult(
const MHRWStatsCollector & ) {
return NoResult(); }
84 static inline ResultType stealResult(MHRWStatsCollector & ) {
return NoResult(); }
86 template<
typename MHRWStatsCollector>
87 struct multistatscoll_result_type_helper<
90 typename std::enable_if<
91 !std::is_same<typename MHRWStatsCollector::ResultType,void>::value,
97 typedef typename MHRWStatsCollector::ResultType ResultType;
98 static inline ResultType getResult(
const MHRWStatsCollector & s) {
return s.getResult(); }
99 static inline ResultType stealResult(MHRWStatsCollector & s) {
return s.stealResult(); }
102 template<
typename ResultType,
typename... MHRWStatsCollectors>
103 struct multistatscoll_result_type_helper2 {
104 typedef std::tuple<MHRWStatsCollectors&...> TupleRefType;
105 typedef std::tuple<MHRWStatsCollectors...> TupleType;
106 template<
typename T,
int... Is>
110 multistatscoll_result_type_helper<
typename std::tuple_element<Is, TupleType>::type>::getResult(
111 std::get<Is>(statscollectors)
115 template<
typename T,
int... Is>
120 multistatscoll_result_type_helper<
typename std::tuple_element<Is, TupleType>::type>::stealResult(
121 std::get<Is>(statscollectors)
166 template<
typename... MHRWStatsCollectors>
174 static constexpr
int NumStatColl =
sizeof...(MHRWStatsCollectors);
182 : statscollectors(statscollectors_...)
191 inline const typename std::tuple_element<I, MHRWStatsCollectorsTupleType>::type & getStatsCollector()
const 193 return std::get<I>(statscollectors);
201 return tomo_internal::multistatscoll_result_type_helper2<ResultType, MHRWStatsCollectors...>::getResult(
208 return tomo_internal::multistatscoll_result_type_helper2<ResultType, MHRWStatsCollectors...>::stealResult(
220 std::get<I>(statscollectors).init();
233 std::get<I>(statscollectors).thermalizingDone();
234 thermalizingDone<I+1>();
246 std::get<I>(statscollectors).done();
257 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk,
int I = 0>
259 CountIntType k,
bool is_thermalizing,
bool is_live_iter,
bool accepted,
260 double a,
const PointType & newpt, FnValueType newptval,
261 const PointType & curpt, FnValueType curptval,
265 std::get<I>(statscollectors).rawMove(
266 k, is_thermalizing, is_live_iter, accepted, a,
267 newpt, newptval, curpt, curptval, rw
269 rawMove<CountIntType, PointType, FnValueType, MHRandomWalk, I+1>(
270 k, is_thermalizing, is_live_iter, accepted, a,
271 newpt, newptval, curpt, curptval, rw
274 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk,
int I = 0>
276 CountIntType,
bool,
bool,
bool,
double,
const PointType &, FnValueType,
285 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk,
int I = 0>
287 CountIntType k, CountIntType n,
const PointType & curpt, FnValueType curptval,
MHRandomWalk & rw
290 std::get<I>(statscollectors).processSample(k, n, curpt, curptval, rw);
291 processSample<CountIntType, PointType, FnValueType, MHRandomWalk, I+1>(k, n, curpt, curptval, rw);
294 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk,
int I = 0>
296 CountIntType, CountIntType,
const PointType &, FnValueType,
MHRandomWalk &
318 template<
typename... MHRWStatsCollectors>
336 template<
typename IterCountIntType_ =
int>
340 typedef IterCountIntType_ IterCountIntType;
343 Eigen::ArrayXi accept_buffer;
344 IterCountIntType pos;
349 : accept_buffer(Eigen::ArrayXi::Zero(num_samples_)), pos(0)
353 inline Eigen::Index bufferSize()
const {
354 return accept_buffer.size();
359 return (
double)accept_buffer.count() / accept_buffer.size();
364 return ( pos >= (IterCountIntType)accept_buffer.size() );
375 inline void thermalizingDone()
387 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename Po
intType2,
typename MHRandomWalk>
389 CountIntType ,
bool ,
bool ,
bool accepted,
390 double , PointType && , FnValueType ,
391 PointType2 && , FnValueType ,
398 accept_buffer[ (Eigen::Index)(pos % (IterCountIntType)accept_buffer.size()) ] = (
int)accepted;
405 template<
typename CountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk>
406 inline void processSample(
407 CountIntType , CountIntType , PointType && , FnValueType ,
MHRandomWalk &&
435 template<
typename ValueCalculator_,
463 HistogramType _histogram;
469 ValueCalculator _vcalc;
471 LoggerType & _logger;
476 const ValueCalculator & vcalc,
478 : _histogram(histogram_params),
535 template<
bool Pr
intHistogram = true>
538 if (PrintHistogram) {
541 _logger.longdebug(
"ValueHistogramMHRWStatsCollector",
542 "Done walking & collecting stats. Here's the histogram:\n" 543 + _histogram.prettyPrint());
549 template<
typename CountIntType,
typename Po
intType,
typename LLHValueType,
typename MHRandomWalk>
550 void rawMove(CountIntType k,
bool ,
bool ,
bool ,
551 double ,
const PointType & , LLHValueType ,
554 _logger.longdebug(
"ValueHistogramMHRWStatsCollector", [&](
std::ostream & stream) {
555 stream <<
"rawMove(): k=" << k;
560 template<
typename CountIntType,
typename Po
intType,
typename LLHValueType,
typename MHRandomWalk>
561 Eigen::Index
processSample(CountIntType k, CountIntType n,
const PointType & curpt,
564 ValueType val = _vcalc.getValue(curpt);
566 _logger.longdebug(
"ValueHistogramMHRWStatsCollector", [&](
std::ostream & stream) {
567 stream <<
"in processSample(): " 568 <<
"k=" << k <<
", n=" << n <<
", val=" << val <<
" -> bin # " 569 << ( _histogram.params.isWithinBounds(val)
572 <<
" [with ValueType=" <<
typeid(ValueType).name() <<
"]" ;
575 return _histogram.record(val);
594 template<
typename HistogramType_,
typename BinningAnalysisParamsType_>
598 typename BinningAnalysisParamsType_::BinSumSqArray
601 typedef HistogramType_ HistogramType;
602 typedef typename HistogramType::Params HistogramParams;
603 typedef BinningAnalysisParamsType_ BinningAnalysisParamsType;
607 : histogram(), error_levels(), converged_status()
619 : histogram(HistogramType::copy(copy.
histogram)),
626 template<
typename EigenDerived1,
typename EigenDerived2>
630 : histogram(HistogramType::copy(histogram_)),
631 error_levels(error_levels_),
632 converged_status(converged_status_)
637 template<
typename BinningAnalysisType>
640 error_levels(b.numTrackValues(), b.numLevels()+1),
641 converged_status(
Eigen::ArrayXi::Constant(b.numTrackValues(), BinningAnalysisType::UNKNOWN_CONVERGENCE))
643 tomographer_assert(converged_status.rows() == b.numTrackValues() && converged_status.cols() == 1);
676 for (
int k = 0; k < converged_status.size(); ++k) {
677 stream <<
"\tval[" <<
std::setw(3) << k <<
"] = " 679 <<
" +- " <<
std::setw(12) << histogram.delta(k);
681 stream <<
" [CONVERGED]";
683 stream <<
" [NOT CONVERGED]";
685 stream <<
" [UNKNOWN]";
687 stream <<
" [INVALID CONVERGENCE STATUS: " << converged_status(k) <<
"]";
697 dumpConvergenceAnalysis(ss);
702 friend boost::serialization::access;
703 template<
typename Archive>
704 void serialize(Archive & a,
unsigned int )
708 a & converged_status;
722 template<
typename ValueCalculator_,
723 typename CountIntType_ = int,
724 typename CountRealAvgType_ = double,
725 int NumTrackValues_ = Eigen::Dynamic,
726 int NumLevels_ = Eigen::Dynamic
739 static constexpr
int NumTrackValues = NumTrackValues_;
741 static constexpr
int NumLevels = NumLevels_;
777 template<
typename Params,
782 typename Params::ValueCalculator,
784 typename Params::BaseHistogramType
786 BinningAnalysis<typename Params::BinningAnalysisParamsType, LoggerType_>,
787 typename Params::Result
816 static constexpr
int NumTrackValuesCTime = Params::NumTrackValues;
818 static constexpr
int NumLevelsCTime = Params::NumLevels;
836 BinningAnalysisType binning_analysis;
845 const ValueCalculator & vcalc,
847 LoggerType & logger_)
848 : value_histogram(histogram_params, vcalc, logger_),
849 binning_analysis((int)histogram_params.num_bins, num_levels, logger_),
851 result(histogram_params, binning_analysis)
853 logger.longdebug(
"ValueHistogramWithBinningMHRWStatsCollector",
"constructor()");
862 inline const BinningAnalysisType & getBinningAnalysis()
const 864 return binning_analysis;
883 const BaseHistogramType & hist = histogram();
884 return hist.bins.template cast<CountRealAvgType>() /
885 (CountRealAvgType)(hist.bins.sum() + hist.off_chart);
908 value_histogram.
init();
918 logger.longdebug(
"ValueHistogramWithBinningMHRWStatsCollector::done()",
"finishing up ...");
920 value_histogram.template done<false>();
931 const BaseHistogramType & h = value_histogram.
histogram();
932 result.histogram.params = h.params;
933 CountRealAvgType numsamples = h.bins.sum() + h.off_chart;
934 result.histogram.bins = h.bins.template cast<CountRealAvgType>() / numsamples;
935 result.error_levels = binning_analysis.
calcErrorLevels(result.histogram.bins);
936 result.histogram.delta = result.error_levels.col(binning_analysis.
numLevels()).
template cast<CountRealAvgType>();
937 result.histogram.off_chart = h.off_chart / numsamples;
941 logger.debug(
"ValueHistogramWithBinningMHRWStatsCollector", [&,
this](
std::ostream & str) {
942 str <<
"Binning analysis: bin sqmeans at different binning levels are:\n" 944 <<
"\t-> so the error bars at different binning levels are:\n" 945 << result.error_levels <<
"\n" 946 <<
"\t-> convergence analysis: \n";
947 result.dumpConvergenceAnalysis(str);
948 str <<
"\t... and just for you, here is the final histogram:\n" << result.histogram.prettyPrint() <<
"\n";
953 template<
typename CountIntType2,
typename Po
intType,
typename LLHValueType,
typename MHRandomWalk>
954 inline void rawMove(CountIntType2 k,
bool is_thermalizing,
bool is_live_iter,
bool accepted,
955 double a,
const PointType & newpt, LLHValueType newptval,
956 const PointType & curpt, LLHValueType curptval,
MHRandomWalk & mh)
958 value_histogram.
rawMove(k, is_thermalizing, is_live_iter, accepted, a, newpt, newptval, curpt, curptval, mh);
962 template<
typename CountIntType2,
typename Po
intType,
typename LLHValueType,
typename MHRandomWalk>
963 inline void processSample(CountIntType2 k, CountIntType2 n,
const PointType & curpt,
966 Eigen::Index histindex = value_histogram.
processSample(k, n, curpt, curptval, mh);
986 typename HistogramType_::Params hist_params,
987 ValueCalculator_ valcalc,
1002 template<
typename ValueCalculator_,
typename CountIntType_ = int,
1003 typename CountRealAvgType_ = double,
int NumTrackValues_ = Eigen::Dynamic,
1004 int NumLevels_ = Eigen::Dynamic,
1009 CountRealAvgType_, NumTrackValues_,
1015 ValueCalculator_ valcalc,
1016 int num_binning_levels,
1023 CountRealAvgType_, NumTrackValues_,
1034 template<
typename MHRWParamsType_>
1038 typedef MHRWParamsType_ MHRWParamsType;
1046 template<
typename PredicateFn,
typename SendStatusFn>
1048 : pred_fn(pred_fn_), send_status_fn(send_status_fn_)
1051 inline void init() { }
1052 inline void thermalizingDone() { }
1053 inline void done() { }
1055 template<
typename IterCountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk>
1056 inline void rawMove(
1057 IterCountIntType k,
bool is_thermalizing,
bool,
bool,
double,
const PointType &, FnValueType,
1064 if ((k % rw.
nSweep() == 0) && pred_fn()) {
1066 MHRWStatusReportType::createFromRandWalkStatInfo(k, is_thermalizing, rw,
1074 template<
typename IterCountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk>
1075 inline void processSample(IterCountIntType, IterCountIntType, PointType&&, FnValueType,
MHRandomWalk &)
1084 template<
typename MHRWParamsType_,
typename ClockType_ =
1086 #if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 6 && !defined(__clang__) 1087 std::chrono::monotonic_clock
1095 typedef MHRWParamsType_ MHRWParamsType;
1098 typedef ClockType_ ClockType;
1099 typedef typename ClockType::time_point TimePoint;
1100 typedef typename ClockType::duration DurationType;
1103 TimePoint last_status_report;
1104 DurationType interval;
1108 template<
typename DurationInit,
typename SendStatusFn>
1110 : interval(interval_), send_status_fn(send_status_fn_)
1113 inline void init() { }
1114 inline void thermalizingDone() { }
1115 inline void done() { }
1117 template<
typename IterCountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk>
1118 inline void rawMove(
1119 IterCountIntType k,
bool is_thermalizing,
bool,
bool,
double,
const PointType &, FnValueType,
1124 if ((k % rw.
nSweep() == 0)) {
1126 auto now = ClockType::now();
1128 if ( interval.count() > 0 && (now - (last_status_report + interval)).count() > 0 ) {
1131 MHRWStatusReportType::createFromRandWalkStatInfo(k, is_thermalizing, rw,
1135 last_status_report = now;
1142 template<
typename IterCountIntType,
typename Po
intType,
typename FnValueType,
typename MHRandomWalk>
1143 inline void processSample(IterCountIntType, IterCountIntType, PointType&&, FnValueType,
MHRandomWalk &)
1166 template<
typename... Args>
1172 static constexpr
int NumStatColl = MHRWStatsCollector::NumStatColl;
1174 static constexpr
bool CanProvideStatusLine =
true;
1176 template<int I = 0, typename std::enable_if<(I < NumStatColl), bool>::type dummy =
true>
1179 typedef typename std::tuple_element<I, typename MHRWStatsCollector::MHRWStatsCollectorsTupleType>::type
1185 getStatusLine<I+1>(stats) );
1188 template<int I = 0, typename std::enable_if<(I == NumStatColl), bool>::type dummy =
true>
1204 template<
typename... Args>
1206 template<
typename... Args>
1214 template<
typename ValueCalculator_,
1215 typename LoggerType_,
1216 typename HistogramType_
1222 static constexpr
bool CanProvideStatusLine =
true;
1224 static inline std::string getStatusLine(
const MHRWStatsCollector * stats)
1226 const int maxbarwidth = 50;
1230 return "Histogram: " + histogramShortBar<HistogramType>(stats->
histogram(),
true, maxbarwidth);
1234 template<
typename ValueCalculator_,
1235 typename LoggerType_,
1236 typename HistogramType_
1245 template<
typename Params_,
1246 typename LoggerType_
1252 static constexpr
bool CanProvideStatusLine =
true;
1254 static inline std::string getStatusLine(
const MHRWStatsCollector * stats)
1256 const int maxbarwidth = 50;
1259 const BaseHistogramType & histogram = stats->
histogram();
1265 const auto& binning_analysis = stats->getBinningAnalysis();
1266 const auto binmeans = stats->
binMeans();
1268 auto error_levels = binning_analysis.calcErrorLevels(binmeans);
1269 auto conv_status = binning_analysis.determineErrorConvergence(error_levels);
1273 return histogramShortBar<BaseHistogramType>(histogram,
true, maxbarwidth)
1275 (
int)conv_summary.n_converged, (int)conv_summary.n_unknown,
1276 (
int)conv_summary.n_not_converged);
1280 template<
typename Params_,
1281 typename LoggerType_
1290 template<
typename CountIntType_>
1293 static constexpr
bool CanProvideStatusLine =
true;
1298 return Tools::fmts(
"acceptance ratio = %.2g (over last %d iter)",
1300 (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.