itpp::Histogram< Num_T > Class Template Reference
Statistics Module » Histogram

Histogram computation class. More...

`#include <itpp/stat/histogram.h>`

## Public Member Functions

| Histogram (Num_T from=Num_T(0), Num_T to=Num_T(99), int n_bins=100)
| ~Histogram ()
| Default destructor.
void | setup (Num_T from, Num_T to, int n_bins)
| Histogram setup.
void | update (Num_T value)
| Histogram update.
void | update (Vec< Num_T > values)
| Histogram update.
void | update (Mat< Num_T > values)
| Histogram update.
void | reset ()
| Bins reset, so accumulation can be restarted.
int | get_bin (int ix) const
| Access to single bin counter.
ivec | get_bins () const
| Access to histogram as a vector.
Vec< Num_T > | get_bin_centers () const
| Access to bin center values (all bins)
Num_T | get_bin_center (int ix) const
| Access to bin center (single bin)
Vec< Num_T > | get_bin_lefts () const
| Access to left boundary of bin intervals (all bins)
Num_T | get_bin_left (int ix) const
| Access to left boundary of single bin.
Vec< Num_T > | get_bin_rights () const
| Access to right boundary of bin intervals (all bins)
Num_T | get_bin_right (int ix) const
| Access to right boundary of single bin.
vec | get_pdf () const
| Experimental Probability Density Function (PDF) computation.
vec | get_cdf () const
| Experimental Cumulative Density Function (CDF) computation.
int | bins_num () const
| Current number of bins.
int | trials_num () const
| Current trials counter.

## Detailed Description

template<typename Num_T>
class itpp::Histogram< Num_T >

Histogram computation class.

Author
  Andy Panov

The Histogram class counts the number of observations of arbitrary numerical types that fall into specified bins. Centers of the leftmost and rightmost bin along with a total number of bins are passed to a histogram object as constructor parameters. Histogram counters are updated when calling update() method. It is possible to access bin counters and bin interval parameters for all bins at once or separately for each bin.

Example:

// Create histogram with 100 bins spanning from 0 to 99 (leftmost bin is
// centered at 0, rightmost bin is centerd at 99).
Histogram<double> hist(0, 99, 100);
// Compute histogram of 100 random variables taken from normal distribution
hist.update(randn(100));
// Get position of bin number 5
double bin5_center = hist.get_bin_center(5);
// Get corresponding bin counter
int bin5_counter = hist.get_bin(5);
// Get bin 5 left boundary:
double bin5_left = hist.get_bin_left(5);
// compute PDF & CDF of experimental data
vec my_data_pdf = hist.get_pdf();
vec my_data_cdf = hist.get_cdf();
itpp::Array
General array class.
Definition array.h:105
itpp::randn
double randn(void)
Generates a random Gaussian (0,1) variable.
Definition random.h:831

Definition at line 75 of file histogram.h.

## Constructor & Destructor Documentation

## ~Histogram()

template<typename Num_T >

itpp::Histogram< Num_T >::~Histogram | ( |  | ) |

inline

Default destructor.

Definition at line 82 of file histogram.h.

## Member Function Documentation

## reset()

template<typename Num_T >

void itpp::Histogram< Num_T >::reset | ( |  | ) |

inline

Bins reset, so accumulation can be restarted.

Definition at line 95 of file histogram.h.

## get_bin()

template<typename Num_T >

int itpp::Histogram< Num_T >::get_bin | ( | int | ix | ) | const

inline

Access to single bin counter.

Definition at line 97 of file histogram.h.

## get_bins()

template<typename Num_T >

ivec itpp::Histogram< Num_T >::get_bins | ( |  | ) | const

inline

Access to histogram as a vector.

Definition at line 99 of file histogram.h.

## get_bin_centers()

template<typename Num_T >

Vec< Num_T > itpp::Histogram< Num_T >::get_bin_centers | ( |  | ) | const

inline

Access to bin center values (all bins)

Definition at line 101 of file histogram.h.

## get_bin_center()

template<typename Num_T >

Num_T itpp::Histogram< Num_T >::get_bin_center | ( | int | ix | ) | const

inline

Access to bin center (single bin)

Definition at line 103 of file histogram.h.

## get_bin_lefts()

template<typename Num_T >

Vec< Num_T > itpp::Histogram< Num_T >::get_bin_lefts | ( |  | ) | const

inline

Access to left boundary of bin intervals (all bins)

Definition at line 105 of file histogram.h.

## get_bin_left()

template<typename Num_T >

Num_T itpp::Histogram< Num_T >::get_bin_left | ( | int | ix | ) | const

inline

Access to left boundary of single bin.

Definition at line 107 of file histogram.h.

## get_bin_rights()

template<typename Num_T >

Vec< Num_T > itpp::Histogram< Num_T >::get_bin_rights | ( |  | ) | const

inline

Access to right boundary of bin intervals (all bins)

Definition at line 109 of file histogram.h.

## get_bin_right()

template<typename Num_T >

Num_T itpp::Histogram< Num_T >::get_bin_right | ( | int | ix | ) | const

inline

Access to right boundary of single bin.

Definition at line 111 of file histogram.h.

## bins_num()

template<typename Num_T >

int itpp::Histogram< Num_T >::bins_num | ( |  | ) | const

inline

Current number of bins.

Definition at line 119 of file histogram.h.

## trials_num()

template<typename Num_T >

int itpp::Histogram< Num_T >::trials_num | ( |  | ) | const

inline

Current trials counter.

Definition at line 121 of file histogram.h.

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

- itpp/stat/histogram.h

Generated on Mon Jun 10 2024 11:49:35 for IT++ by Doxygen 1.9.8