Tomographer  v5.4
Tomographer C++ Framework Documentation
Tomographer::HistogramWithErrorBars< Scalar_, CountType_ > Class Template Reference

Stores a histogram along with error bars. More...

#include <tomographer/histogram.h>

+ Inheritance diagram for Tomographer::HistogramWithErrorBars< Scalar_, CountType_ >:
+ Collaboration diagram for Tomographer::HistogramWithErrorBars< Scalar_, CountType_ >:

Public Types

typedef Scalar_ Scalar
 The Scalar (X-axis) Type. See Histogram::Scalar.
 
typedef CountType_ CountType
 The Type used to keep track of counts. See Histogram::CountType.
 
typedef Histogram< Scalar_, CountType_ > Base_
 Shortcut for our base class type.
 
typedef Base_::Params Params
 Shortcut for our base class' histogram parameters. See Histogram::Params.
 
- Public Types inherited from Tomographer::Histogram< 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 HistogramParams< Scalar_ > Params
 The type for specifying parameters of this histogram (limits, number of bins)
 

Public Member Functions

 HistogramWithErrorBars (Params params=Params())
 Constructor, with given histogram parameters. More...
 
 HistogramWithErrorBars (Scalar min, Scalar max, Eigen::Index num_bins)
 Constructor, with given histogram parameters. More...
 
 HistogramWithErrorBars (HistogramWithErrorBars &&x)
 Constructor: move another histogram type.
 
 HistogramWithErrorBars (const HistogramWithErrorBars &x)
 Constructor: copy another histogram type.
 
void reset ()
 Resets the histogram to zero counts everywhere, and zero error bars. More...
 
CountType errorBar (Eigen::Index i) const
 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>
HistogramWithErrorBars< Scalar, NewCountType > normalized () const
 Get a normalized version of this histogram. More...
 
template<typename NewCountType = Scalar>
HistogramWithErrorBars< Scalar, NewCountType > normalizedCounts () const
 Get a version of this histogram, normalized by total counts. More...
 
std::string prettyPrint (int max_width=0) const
 Print the histogram in human readable form. More...
 
- Public Member Functions inherited from Tomographer::Histogram< Scalar_, CountType_ >
template<typename Params2 = Params>
 Histogram (Params2 p=Params2())
 Constructor: stores the parameters and initializes the histogram to zero counts everywhere.
 
 Histogram (Scalar min_, Scalar max_, Eigen::Index num_bins)
 Constructor: stores the parameters and initializes the histogram to zero counts everywhere.
 
 Histogram (Histogram &&x)
 Constructor: move another histogram type.
 
 Histogram (const Histogram &x)
 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 Histogram< OtherScalar, OtherCountType > &x)
 Add data to the histogram. More...
 
Eigen::Index numBins () const
 Shorthand for params.num_bins
 
CountType count (Eigen::Index i) const
 Shorthand for bins(i)
 
bool isWithinBounds (Scalar value) const
 Shorthand for Params::isWithinBounds()
 
Eigen::Index binIndex (Scalar value) const
 Shorthand for Params::binIndex()
 
Scalar binLowerValue (Eigen::Index index) const
 Shorthand for Params::binLowerValue()
 
Scalar binCenterValue (Eigen::Index index) const
 Shorthand for Params::binCenterValue()
 
Scalar binUpperValue (Eigen::Index index) const
 Shorthand for Params::binUpperValue()
 
Scalar binResolution () const
 Shorthand for Params::binResolution()
 
Eigen::Index record (Scalar value)
 Record a new value in the histogram. More...
 
Eigen::Index 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>
Histogram< Scalar, NewCountType > normalized () const
 Get a normalized version of this histogram. More...
 
CountType totalCounts () const
 Return the total number of histogram counts (no normalization) More...
 
template<typename NewCountType = Scalar>
Histogram< Scalar, NewCountType > normalizedCounts () const
 Get a version of this histogram, normalized by total counts. More...
 
std::string prettyPrint (int max_width=0) const
 Pretty-print the histogram and return it as a string with horizontal bars. More...
 

Static Public Member Functions

template<typename HistogramType , ENABLED_IF( HistogramType::HasErrorBars==1) >
static HistogramWithErrorBars copy (const HistogramType &other)
 explicitly copy another histogram type
 
- Static Public Member Functions inherited from Tomographer::Histogram< Scalar_, CountType_ >
template<typename HistogramType , ENABLED_IF( HistogramType::HasErrorBars==0|| HistogramType::HasErrorBars==1) >
static Histogram copy (const HistogramType &other)
 explicitly copy another histogram type
 

Public Attributes

Eigen::Array< CountType, Eigen::Dynamic, 1 > delta
 The error bars associated with each histogram bin.
 
- Public Attributes inherited from Tomographer::Histogram< 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
 This type of histogram does provide error bars.
 
- Static Public Attributes inherited from Tomographer::Histogram< Scalar_, CountType_ >
static constexpr bool HasErrorBars = false
 This histogram type does not provide error bars.
 

Detailed Description

template<typename Scalar_, typename CountType_ = double>
class Tomographer::HistogramWithErrorBars< Scalar_, CountType_ >

Stores a histogram along with error bars.

Builds on top of Histogram<Scalar,CountType> to store error bars corresponding to each bin.

Since
Since Tomographer 5.3, this class can be serialized with Boost.Serialization.

Definition at line 566 of file histogram.h.

Constructor & Destructor Documentation

§ HistogramWithErrorBars() [1/2]

template<typename Scalar_, typename CountType_ = double>
Tomographer::HistogramWithErrorBars< Scalar_, CountType_ >::HistogramWithErrorBars ( Params  params = Params())
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 600 of file histogram.h.

§ HistogramWithErrorBars() [2/2]

template<typename Scalar_, typename CountType_ = double>
Tomographer::HistogramWithErrorBars< Scalar_, CountType_ >::HistogramWithErrorBars ( Scalar  min,
Scalar  max,
Eigen::Index  num_bins 
)
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 610 of file histogram.h.

Member Function Documentation

§ errorBar()

template<typename Scalar_, typename CountType_ = double>
CountType Tomographer::HistogramWithErrorBars< Scalar_, CountType_ >::errorBar ( Eigen::Index  i) const
inline

Get error bar for bin number i.

This simply returns delta(i).

Definition at line 659 of file histogram.h.

§ load()

template<typename Scalar_, typename CountType_ = double>
template<typename EigenType , typename EigenType2 = EigenType>
void Tomographer::HistogramWithErrorBars< Scalar_, CountType_ >::load ( const Eigen::DenseBase< EigenType > &  d,
const Eigen::DenseBase< EigenType2 > &  derr,
CountType  off_chart_ = 0 
)
inline

Load data for the histogram. Uses current histogram parameters, just sets the bin counts and the error bars.

Parameters
dis 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.
derris 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 678 of file histogram.h.

§ normalized()

template<typename Scalar_, typename CountType_ = double>
template<typename NewCountType = Scalar>
HistogramWithErrorBars<Scalar, NewCountType> Tomographer::HistogramWithErrorBars< Scalar_, CountType_ >::normalized ( ) const
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.

See also normalizedCounts().

Definition at line 697 of file histogram.h.

§ normalizedCounts()

template<typename Scalar_, typename CountType_ = double>
template<typename NewCountType = Scalar>
HistogramWithErrorBars<Scalar, NewCountType> Tomographer::HistogramWithErrorBars< Scalar_, CountType_ >::normalizedCounts ( ) const
inline

Get a version of this histogram, normalized by total counts.

This function divides the bins and the off chart counts by the total number of counts (including off-chart). This function ignores the normalization() and thus any scale given by the x-axis. Use this normalization if you would like each individual bin to represent the average number of points which fall into that bin.

If on the other hand you would like each bin to represent the probability density of falling into that bin, you should use normalized() instead.

Definition at line 718 of file histogram.h.

§ prettyPrint()

template<typename Scalar_, typename CountType_ = double>
std::string Tomographer::HistogramWithErrorBars< Scalar_, CountType_ >::prettyPrint ( int  max_width = 0) const
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.

Parameters
max_widththe maximum line length the displayed histogram should fit in.

Definition at line 754 of file histogram.h.

§ reset()

template<typename Scalar_, typename CountType_ = double>
void Tomographer::HistogramWithErrorBars< Scalar_, CountType_ >::reset ( )
inline

Resets the histogram to zero counts everywhere, and zero error bars.

Warning
the corresponding base class has NO virtual methods. So don't see this class inheritance as object polymorphism. If you need to reset a uniform bins histogram with error bars, you need to know its type.

Definition at line 648 of file histogram.h.


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