Tomographer  v5.4
Tomographer C++ Framework Documentation
Tomographer::AggregatedHistogramWithErrorBars< HistogramType_, CountRealType_ > Class Template Reference

Histogram aggregator, if each individual histogram already has error bars. More...

#include <tomographer/histogram.h>

+ Inheritance diagram for Tomographer::AggregatedHistogramWithErrorBars< HistogramType_, CountRealType_ >:
+ Collaboration diagram for Tomographer::AggregatedHistogramWithErrorBars< HistogramType_, CountRealType_ >:

Public Types

typedef HistogramType_ HistogramType
 The histogram type corresponding to the result of a task. More...
 
typedef HistogramType::Params HistogramParams
 The parameters type used to describe our histogram range and number of bins.
 
typedef HistogramType::Scalar HistogramScalarType
 The scalar type of the histogram (i.e., x-axis labels)
 
typedef CountRealType_ CountRealType
 Type used for averaged histogram counts (e.g. double)
 
typedef AveragedHistogram< HistogramType, CountRealTypeFinalHistogramType
 The type of the final resulting, averaged histogram.
 
typedef Histogram< typename HistogramType::Scalar, typename HistogramType::CountType > SimpleHistogramType
 The "simple" histogram, as if without binning analysis. More...
 
typedef AveragedHistogram< SimpleHistogramType, CountRealTypeSimpleFinalHistogramType
 Properly averaged "simple" histogram, with naive statistical standard deviation error bars from the several task runs.
 

Public Member Functions

 AggregatedHistogramWithErrorBars (AggregatedHistogramWithErrorBars &&x)
 
 AggregatedHistogramWithErrorBars (FinalHistogramType &&x, SimpleFinalHistogramType &&y)
 
void printHistogramCsv (std::ostream &stream, const std::string sep="\, const std::string linesep="\", const int precision=10)
 Produce a comma-separated-value (CSV) representation of the final aggregated histogram data. More...
 

Static Public Member Functions

template<typename ContainerType , typename ExtractHistogramFn >
static AggregatedHistogramWithErrorBars aggregate (const HistogramParams &params, const ContainerType &list, ExtractHistogramFn extract_histogram_fn)
 Aggregate a list of histograms. More...
 

Public Attributes

FinalHistogramType final_histogram
 The final histogram, properly combining the error bars of each histogram.
 
SimpleFinalHistogramType simple_final_histogram
 The "naive" final histogram, ignoring the error bars of each histogram (see class doc)
 

Detailed Description

template<typename HistogramType_, typename CountRealType_>
class Tomographer::AggregatedHistogramWithErrorBars< HistogramType_, CountRealType_ >

Histogram aggregator, if each individual histogram already has error bars.

This class takes care of combining histograms together into a final, averaged histogram with error bars.

Two histograms are provided. The final_histogram is the properly averaged histogram built by averaging the histograms and combining the error bars together (see AveragedHistogram). Use this one.

The histogram simple_final_histogram, is a histogram built by averaging the histograms, but ignoring their error bars and simply calculating the error bars with the standard deviation of the different histograms as if each individual histogram didn't have error bars. If you have enough different histograms, these error bars may also be meaningful, and can be used to compare to the error bars given by each histogram. This can be useful, for instance, to test a binning analysis procedure to make sure that the error bars from that procedure are of same order of magnitude as "naive" error bars from individual runs.

If you're using the Tomographer::MHRWTasks::ValueHistogramTools tools, note that you can directly get the right HistogramAggregator type by calling the method CDataBase::aggregateResultHistograms() using your MHRandomWalkCData class deriving from Tomographer::MHRWTasks::ValueHistogramTools::CDataBase.

Use the static aggregate() function to construct an object instance, aggregating histograms from a list.

Definition at line 1218 of file histogram.h.

Member Typedef Documentation

§ HistogramType

template<typename HistogramType_ , typename CountRealType_ >
typedef HistogramType_ Tomographer::AggregatedHistogramWithErrorBars< HistogramType_, CountRealType_ >::HistogramType

The histogram type corresponding to the result of a task.

Warning
This histogram type must provide error bars.

Definition at line 1231 of file histogram.h.

§ SimpleHistogramType

template<typename HistogramType_ , typename CountRealType_ >
typedef Histogram<typename HistogramType::Scalar, typename HistogramType::CountType> Tomographer::AggregatedHistogramWithErrorBars< HistogramType_, CountRealType_ >::SimpleHistogramType

The "simple" histogram, as if without binning analysis.

Definition at line 1251 of file histogram.h.

Member Function Documentation

§ aggregate()

template<typename HistogramType_ , typename CountRealType_ >
template<typename ContainerType , typename ExtractHistogramFn >
static AggregatedHistogramWithErrorBars Tomographer::AggregatedHistogramWithErrorBars< HistogramType_, CountRealType_ >::aggregate ( const HistogramParams params,
const ContainerType &  list,
ExtractHistogramFn  extract_histogram_fn 
)
inlinestatic

Aggregate a list of histograms.

Construct a AggregatedHistogramWithErrorBars by aggregating a list of histograms given as list. The list might contain more complicated objects from which the relevant histogram is to be extracted, the callable extract_histogram_fn is called to extract the histogram. For instance, list may be a list of run task results which contain a histogram (among other info).

Parameters
paramsThe histogram parameters to initialize the final histogram with.
Warning
No check is made that the params matches the parameters of each aggregated histogram.
Parameters
listThe list of objects from which to extract a histogram. This should be some container type; the only requirement is that one should be able to iterate over it with a range-for loop with a "const auto&" item.
extract_histogram_fnA callable which is called for each item of the list; it is provided a single argument, the list item, and is expected to return the histogram which will be aggregated with the others.

See also Tomographer::MHRWTasks::ValueHistogramTools::CDataBase::aggregateResultHistograms()

Definition at line 1303 of file histogram.h.

§ printHistogramCsv()

template<typename HistogramType_ , typename CountRealType_ >
void Tomographer::AggregatedHistogramWithErrorBars< HistogramType_, CountRealType_ >::printHistogramCsv ( std::ostream stream,
const std::string  sep = "\t",
const std::string  linesep = "\n",
const int  precision = 10 
)
inline

Produce a comma-separated-value (CSV) representation of the final aggregated histogram data.

The histogram data is written in CSV format on the C++ output stream stream. You may specify the cell separator sep (by default a TAB char), the line separator (by default a simple newline), and the precision used when exporting the values. Numbers are written in scientific format (e.g. 1.205115485e-01).

The output consists of four columns. Titles are printed on the first line ("Value", "Counts", "Error", "SimpleError"). The first column holds the values, i.e., the x-axis of the histogram; the second column holds the counts (normalized to the number of samples); the third column holds the error bar on the counts (reliable error bar from binning analysis), and the fourth column holds the naive error bar obtained when we ignore the binning analysis.

Definition at line 1345 of file histogram.h.


The documentation for this class was generated from the following file: