yat
0.14.5pre
|
Histograms provide a convenient way of presenting the distribution of a set of data. More...
#include <yat/statistics/Histogram.h>
Public Member Functions | |
Histogram (void) | |
Histogram (std::istream &) | |
The istream constructor. More... | |
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. More... | |
const AveragerWeighted & | averager_all (void) const |
Average of all events presented to the histogram. More... | |
const AveragerWeighted & | averager_histogram (void) const |
Average of events fitting within histogram. More... | |
size_t | nof_bins (void) const |
void | normalize (bool choice=true) |
Normalizing the histogram. More... | |
double | observation_value (const size_t k) const |
void | rescale (double factor) |
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 &) |
const Histogram & | operator+= (const Histogram &rhs) |
Addition operator. More... | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename Iterator > | |
void | add (Histogram &h, Iterator first, Iterator last) |
std::ostream & | operator<< (std::ostream &s, const Histogram &) |
Histograms provide a convenient way of presenting the distribution of a set of data.
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 | ( | std::istream & | ) |
The istream constructor.
This constructor creates a Histogram from output (possibly) created with operator<<. Note that the output from operator<< does not contain all information required to restore the Histogram. The values of all bins are restored, but the averagers, averager_all(void) and averager_histogram(void), and more specifically the second moment (sum_xx) in the averagers cannot be restored due to lack of information in the output.
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 |
Addition operator.
The assignment operator
double theplu::yat::statistics::Histogram::operator[] | ( | size_t | k | ) | const |
void theplu::yat::statistics::Histogram::rescale | ( | double | factor | ) |
multiply value of each bin with factor
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 |
|
related |
Add a range [first, last) of values to Histogram.
Type Requirements:
Iterator
models a Data IteratorIterator
models a Single Pass Iterator
|
related |
The Histogram output operator