Tomographer
v3.0
Tomographer C++ Framework Documentation
|
Stores a histogram along with error bars. More...
#include <tomographer/histogram.h>
Public Types | |
typedef Scalar_ | Scalar |
The Scalar (X-axis) Type. See UniformBinsHistogram::Scalar. | |
typedef CountType_ | CountType |
The Type used to keep track of counts. See UniformBinsHistogram::CountType. | |
typedef UniformBinsHistogram< Scalar_, CountType_ > | Base_ |
Shortcut for our base class type. | |
typedef Base_::Params | Params |
Shortcut for our base class' histogram parameters. See UniformBinsHistogram::Params. | |
Public Types inherited from Tomographer::UniformBinsHistogram< Scalar_, CountType_ > | |
typedef Scalar_ | Scalar |
The scalar type of the "X"-axis of the histogram (usually double ) | |
typedef CountType_ | CountType |
The type that serves to count how many hits in each bin. | |
typedef UniformBinsHistogramParams< Scalar_ > | Params |
The type for specifying parameters of this histogram (limits, number of bins) | |
Public Types inherited from Tomographer::Tools::EigenAlignedOperatorNewProvider | |
typedef EigenAlignedOperatorNewProvider | OperatorNewProviderType |
Public Member Functions | |
UniformBinsHistogramWithErrorBars (Params params=Params()) | |
Constructor, with given histogram parameters. More... | |
UniformBinsHistogramWithErrorBars (Scalar min, Scalar max, std::size_t num_bins) | |
Constructor, with given histogram parameters. More... | |
void | reset () |
Resets the histogram to zero counts everywhere, and zero error bars. More... | |
CountType | errorBar (std::size_t i) const |
For the Histogram Interface. Get error bar for bin number i. More... | |
template<typename EigenType , typename EigenType2 = EigenType> | |
void | load (const Eigen::DenseBase< EigenType > &d, const Eigen::DenseBase< EigenType2 > &derr, CountType off_chart_=0) |
Load data for the histogram. Uses current histogram parameters, just sets the bin counts and the error bars. More... | |
template<typename NewCountType = Scalar> | |
UniformBinsHistogramWithErrorBars< Scalar, NewCountType > | normalized () const |
Get a normalized version of this histogram. More... | |
std::string | prettyPrint (int max_width=0) const |
Print the histogram in human readable form. More... | |
Public Member Functions inherited from Tomographer::UniformBinsHistogram< Scalar_, CountType_ > | |
template<typename Params2 = Params, decltype((int) std::declval< const Params2 >().min+(int) std::declval< const Params2 >().max+std::declval< Params2 >().num_bins) dummyval = 0> | |
UniformBinsHistogram (Params2 p=Params()) | |
Constructor: stores the parameters and initializes the histogram to zero counts everywhere. | |
UniformBinsHistogram (Scalar min_, Scalar max_, std::size_t num_bins) | |
Constructor: stores the parameters and initializes the histogram to zero counts everywhere. | |
template<typename HistogramType , ENABLED_IF( HistogramType::HasErrorBars==0||HistogramType::HasErrorBars==1) > | |
UniformBinsHistogram (const HistogramType &other) | |
Constructor: copy another histogram type. | |
void | reset () |
Resets the histogram to zero counts everywhere (including the off-chart counts) | |
template<typename EigenType > | |
void | load (const Eigen::DenseBase< EigenType > &x, CountType off_chart_=0) |
Load data for the histogram. Uses current histogram parameters, just sets the bin counts. More... | |
template<typename EigenType > | |
void | add (const Eigen::ArrayBase< EigenType > &x, CountType off_chart_=0) |
Add data to the histogram. More... | |
template<typename OtherScalar , typename OtherCountType > | |
void | add (const UniformBinsHistogram< OtherScalar, OtherCountType > &x) |
Add data to the histogram. More... | |
std::size_t | numBins () const |
Shorthand for params.num_bins | |
CountType | count (std::size_t i) const |
Shorthand for bins(i) | |
bool | isWithinBounds (Scalar value) const |
Shorthand for Params::isWithinBounds() | |
std::size_t | binIndex (Scalar value) const |
Shorthand for Params::binIndex() | |
Scalar | binLowerValue (int index) const |
Shorthand for Params::binLowerValue() | |
Scalar | binCenterValue (std::size_t index) const |
Shorthand for Params::binCenterValue() | |
Scalar | binUpperValue (std::size_t index) const |
Shorthand for Params::binUpperValue() | |
Scalar | binResolution () const |
Shorthand for Params::binResolution() | |
std::size_t | record (Scalar value) |
Record a new value in the histogram. More... | |
std::size_t | record (Scalar value, CountType weight) |
Record a new value in the histogram, with a certain weight. More... | |
template<typename NewCountType = decltype(Scalar(1) + CountType(1))> | |
NewCountType | normalization () const |
Calculate the total weight stored in this histogram. More... | |
template<typename NewCountType = Scalar> | |
UniformBinsHistogram< Scalar, NewCountType > | normalized () const |
Get a normalized version of this histogram. More... | |
std::string | prettyPrint (int max_width=0) const |
Pretty-print the histogram and return it as a string with horizontal bars. More... | |
Public Attributes | |
Eigen::Array< CountType, Eigen::Dynamic, 1 > | delta |
The error bars associated with each histogram bin. | |
Public Attributes inherited from Tomographer::UniformBinsHistogram< Scalar_, CountType_ > | |
Params | params |
Parameters of this histogram (range and # of bins) | |
Eigen::Array< CountType, Eigen::Dynamic, 1 > | bins |
The counts for each bin. | |
CountType | off_chart |
The number of points that fell outside of the given range. | |
Static Public Attributes | |
static constexpr bool | HasErrorBars = true |
For the Histogram Interface. This type of histogram does provide error bars. | |
Static Public Attributes inherited from Tomographer::UniformBinsHistogram< Scalar_, CountType_ > | |
static constexpr bool | HasErrorBars = false |
This histogram type does not provide error bars (see Histogram Interface) | |
Stores a histogram along with error bars.
Builds on top of UniformBinsHistogram<Scalar,CountType> to store error bars corresponding to each bin.
Definition at line 474 of file histogram.h.
|
inline |
Constructor, with given histogram parameters.
Constructs an empty histogram with the given parameters. All bin counts, off-chart counts and delta error bars are initialized to zero.
Definition at line 508 of file histogram.h.
|
inline |
Constructor, with given histogram parameters.
Constructs an empty histogram with the given parameters. All bin counts, off-chart counts and delta error bars are initialized to zero.
Definition at line 518 of file histogram.h.
|
inline |
For the Histogram Interface. Get error bar for bin number i.
This simply returns delta(i)
.
Definition at line 540 of file histogram.h.
|
inline |
Load data for the histogram. Uses current histogram parameters, just sets the bin counts and the error bars.
d | is an Eigen Vector or 1-D Array from which to load the data for the bin counts. It must be dense, have one column and exactly numBins() rows. |
derr | is an Eigen Vector or 1-D Array from which to load the data for the error bars. It must be dense, have one column and exactly numBins() rows. |
off_chart_ | if provided, then set the off_chart count to this number. Otherwise, reset the off_chart counts to zero. |
Definition at line 559 of file histogram.h.
|
inline |
Get a normalized version of this histogram.
This function divides the bins, the error bars and the off chart counts by the appropriate normalization() and stores these values into a new returned histogram.
Definition at line 577 of file histogram.h.
|
inline |
Print the histogram in human readable form.
Returns a string which can be e.g. printed to the terminal, which produces a visual representation of the histogram.
max_width | the maximum line length the displayed histogram should fit in. |
Definition at line 606 of file histogram.h.
|
inline |
Resets the histogram to zero counts everywhere, and zero error bars.
Definition at line 529 of file histogram.h.