#include <yat/statistics/Histogram.h>
Public Member Functions | |
Histogram (void) | |
Histogram (const Histogram &) | |
Histogram (const double xmin, const double xmax, const size_t n) | |
int | add (const double x, const double weight=1.0) |
Add a data point to the histogram. | |
const AveragerWeighted & | averager_all (void) const |
Average of all events presented to the histogram. | |
const AveragerWeighted & | averager_histogram (void) const |
Average of events fitting within histogram. | |
size_t | nof_bins (void) const |
void | normalize (bool choice=true) |
Normalizing the histogram. | |
double | observation_value (const size_t k) const |
void | reset (void) |
double | spacing (void) const |
double | xmax (void) const |
double | xmin (void) const |
double | operator[] (size_t k) const |
const Histogram & | operator= (const Histogram &) |
A histogram consists of a set of bins which count the number of events falling into these bins. Currently only one dimensional histograms with uniformly spaced bins are supported.
theplu::yat::statistics::Histogram::Histogram | ( | void | ) |
The default constructor.
theplu::yat::statistics::Histogram::Histogram | ( | const Histogram & | ) |
The copy constructor.
theplu::yat::statistics::Histogram::Histogram | ( | const double | xmin, | |
const double | xmax, | |||
const size_t | n | |||
) |
Construct a histogram object that covers with the bin spacing .
int theplu::yat::statistics::Histogram::add | ( | const double | x, | |
const double | weight = 1.0 | |||
) |
Add a data point to the histogram.
Update the histogram by adding weight to the bin whose range contains the observation x. No bins are updated when x lies outside the range of the histogram but the value is added to the overall integral of the histogram.
const AveragerWeighted& theplu::yat::statistics::Histogram::averager_all | ( | void | ) | const |
Average of all events presented to the histogram.
Gives access to the AveragerWeighted object that keeps track of average of all events presented to the histogram.
const AveragerWeighted& theplu::yat::statistics::Histogram::averager_histogram | ( | void | ) | const |
Average of events fitting within histogram.
Gives access to the AveragerWeighted object that keeps track of average of events that fits within the histogram lower and upper limits. This function is equivalent to averager().
size_t theplu::yat::statistics::Histogram::nof_bins | ( | void | ) | const |
void theplu::yat::statistics::Histogram::normalize | ( | bool | choice = true |
) |
Normalizing the histogram.
There are two ways to normalize the counts.
If choice is true: The normalized count is the count in a bin divided by the total number of observations. In this case the relative counts are normalized to sum to unity ( minus values outside histogram). This is the intuitive case where the height of the histogram bar represents the proportion of the data in each class.
If choice is false: The normalized count is the count in the class divided by the number of observations times the bin width. For this normalization, the area (or integral) under the histogram is equal to unity (minus the missing area corresponding to counts outside histogram). From a probabilistic point of view, this normalization results in a relative histogram that is most akin to the probability density function If you want to overlay a probability density on top of the histogram, use this normalization. Although this normalization is less intuitive (relative frequencies greater than 1 are quite permissible), it is the appropriate normalization if you are using the histogram to model a probability density function.
double theplu::yat::statistics::Histogram::observation_value | ( | const size_t | k | ) | const |
void theplu::yat::statistics::Histogram::reset | ( | void | ) |
Set everyting to default values, here it means that everything is set to zero except the boundary values that are kept.
double theplu::yat::statistics::Histogram::spacing | ( | void | ) | const |
double theplu::yat::statistics::Histogram::xmax | ( | void | ) | const |
double theplu::yat::statistics::Histogram::xmin | ( | void | ) | const |
double theplu::yat::statistics::Histogram::operator[] | ( | size_t | k | ) | const |
The assignment operator