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

Histogram aggregator, if each histogram doesn't have error bars. More...

#include <tomographer/histogram.h>

+ Inheritance diagram for Tomographer::AggregatedHistogramSimple< HistogramType_, CountRealType_ >:
+ Collaboration diagram for Tomographer::AggregatedHistogramSimple< 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. More...
 

Public Member Functions

 AggregatedHistogramSimple (AggregatedHistogramSimple &&x)
 
 AggregatedHistogramSimple (FinalHistogramType &&x)
 
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 AggregatedHistogramSimple 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, with error bars.
 

Detailed Description

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

Histogram aggregator, if each histogram doesn't have error bars.

This class takes care of combining histograms together into a final, averaged histogram with error bars, using a AveragedHistogram. The error bars are simply determined from the standard deviation of the different histograms.

Warning
The error bars are only meaningful if you're averaging enough different histograms (so that the statistical standard deviation is meaningful)

The only advantage of this class over using a AveragedHistogram directly is that you can aggregate a list of histograms in one call, see aggregate(). It also provides a very similar API to AggregatedHistogramWithErrorBars.

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.

Since
Added in Tomographer 5.0.

Definition at line 1012 of file histogram.h.

Member Typedef Documentation

§ FinalHistogramType

template<typename HistogramType_ , typename CountRealType_ >
typedef AveragedHistogram<HistogramType, CountRealType> Tomographer::AggregatedHistogramSimple< HistogramType_, CountRealType_ >::FinalHistogramType

The type of the final resulting, averaged histogram.

Definition at line 1038 of file histogram.h.

§ HistogramType

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

The histogram type corresponding to the result of a task.

Warning
This histogram type must not provide error bars.

Definition at line 1022 of file histogram.h.

Member Function Documentation

§ aggregate()

template<typename HistogramType_ , typename CountRealType_ >
template<typename ContainerType , typename ExtractHistogramFn >
static AggregatedHistogramSimple Tomographer::AggregatedHistogramSimple< 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 1081 of file histogram.h.

§ printHistogramCsv()

template<typename HistogramType_ , typename CountRealType_ >
void Tomographer::AggregatedHistogramSimple< 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).

Three columns are outputted. Titles are outputted on the first line ("Value", "Counts" and "Error"). 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 the error bar on the counts.

Definition at line 1112 of file histogram.h.


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