#include <DynamicHistogram.h>
Public Member Functions | |
| DynamicHistogram () | |
| Default constructor. | |
| DynamicHistogram (T inc) | |
| Default constructor taking bin increment. | |
| DynamicHistogram (const DynamicHistogram &rhs) | |
| Copy constructor. | |
| T | GetBinSize () const |
| Returns the size of each bin. | |
| void | CombineWith (const DynamicHistogram &rhs) |
| Addition function. | |
| void | SetBinSize (T size) |
| Sets the bin size. | |
| double & | operator[] (int i) |
| Indexing operator. | |
| void | Insert (T value) |
| Inserts a datapoint into the histogram is the value to be inserted. | |
| void | Insert (T value, double weight) |
| Inserts a datapoint into the histogram is the value to be inserted is the weight of the datapoint. | |
| void | Clear () |
| Clears the contents of the histogram. | |
| void | Reset () |
| Clears the contents of the histogram. | |
| void | Print () |
| Prints the histogram to stdout. | |
| void | Print (std::ostream &os) |
| Prints the histogram to a stream is the stream to print to. | |
| unsigned int | GetNumberOfBins () const |
| Returns the number of bins in the histogram. | |
| std::pair< T, T > | GetBin (unsigned int i) |
| Returns the number of bins in the histogram. | |
| std::pair< T, T > | Max () |
Protected Types | |
| enum | { TOO_SMALL = -2, TOO_BIG = -1 } |
Protected Member Functions | |
| void | ExpandRight (T value, double weight) |
| Expands the histogram in the positive x direction is the value of the out-of-bounds data point is the weight of the point. | |
| void | ExpandLeft (T value, double weight) |
| Expands the histogram in the negative x direction is the value of the out-of-bounds datapoint is the weight of the point. | |
| int | ComputeBinContaining (T value) |
| Computes the bin number containing a given datapoint is the value of the datapoint. | |
| void | CreateFirstBin (T value, double weight) |
| Creates the initial bin in the histogram. | |
Protected Attributes | |
| std::deque< double > | mWeightOfBin |
| Dynamic sized container holding the weight associated with each bin. | |
| T | mMin |
| Minumum bound of the histogram. | |
| T | mMax |
| Maximum bound of the histogram. | |
| T | mInc |
| Increment of the histogram. | |
| bool | mIsFirstTime |
| Indicates whether the first bin exists. | |
#include <stdlib.h> //gives us the drand48() random number generator used in the example #include <iostream> //gives us std::cerr used in the example #include <glotzmath.h> using namespace glotzmath; int main() { DynamicHistogram <double> h(0.1); //histogram "h" binning values of type double with binsize 0.1 h.Insert(drand48()); //insert a random double [0,1] h += drand48(); //another way to add a value to h h.Insert(5); //doesn't matter that it is out of bounds, h will resize to accomadate it h.Remove(drand48()); //de-increment the bin containing a number h -= drand48(); //another way to do it h.Print(); //Print to stdout h.Print(std::cerr); //Print to stderr }
| glotzmath::DynamicHistogram< T >::DynamicHistogram | ( | ) | [inline] |
Default constructor.
| glotzmath::DynamicHistogram< T >::DynamicHistogram | ( | T | inc | ) | [inline] |
Default constructor taking bin increment.
| glotzmath::DynamicHistogram< T >::DynamicHistogram | ( | const DynamicHistogram< T > & | rhs | ) | [inline] |
Copy constructor.
| T glotzmath::DynamicHistogram< T >::GetBinSize | ( | ) | const [inline] |
Returns the size of each bin.
| void glotzmath::DynamicHistogram< T >::CombineWith | ( | const DynamicHistogram< T > & | rhs | ) | [inline] |
Addition function.
| void glotzmath::DynamicHistogram< T >::SetBinSize | ( | T | size | ) | [inline] |
Sets the bin size.
| double& glotzmath::DynamicHistogram< T >::operator[] | ( | int | i | ) | [inline] |
Indexing operator.
| void glotzmath::DynamicHistogram< T >::Insert | ( | T | value | ) | [inline] |
Inserts a datapoint into the histogram is the value to be inserted.
| void glotzmath::DynamicHistogram< T >::Insert | ( | T | value, | |
| double | weight | |||
| ) | [inline] |
Inserts a datapoint into the histogram is the value to be inserted is the weight of the datapoint.
| void glotzmath::DynamicHistogram< T >::Clear | ( | ) | [inline] |
| void glotzmath::DynamicHistogram< T >::Reset | ( | ) | [inline] |
| void glotzmath::DynamicHistogram< T >::Print | ( | ) | [inline] |
Prints the histogram to stdout.
| void glotzmath::DynamicHistogram< T >::Print | ( | std::ostream & | os | ) | [inline] |
Prints the histogram to a stream is the stream to print to.
| unsigned int glotzmath::DynamicHistogram< T >::GetNumberOfBins | ( | ) | const [inline] |
Returns the number of bins in the histogram.
| std::pair<T, T> glotzmath::DynamicHistogram< T >::GetBin | ( | unsigned int | i | ) | [inline] |
Returns the number of bins in the histogram.
| std::pair<T, T> glotzmath::DynamicHistogram< T >::Max | ( | ) | [inline] |
| void glotzmath::DynamicHistogram< T >::ExpandRight | ( | T | value, | |
| double | weight | |||
| ) | [inline, protected] |
Expands the histogram in the positive x direction is the value of the out-of-bounds data point is the weight of the point.
| void glotzmath::DynamicHistogram< T >::ExpandLeft | ( | T | value, | |
| double | weight | |||
| ) | [inline, protected] |
Expands the histogram in the negative x direction is the value of the out-of-bounds datapoint is the weight of the point.
| int glotzmath::DynamicHistogram< T >::ComputeBinContaining | ( | T | value | ) | [inline, protected] |
Computes the bin number containing a given datapoint is the value of the datapoint.
| void glotzmath::DynamicHistogram< T >::CreateFirstBin | ( | T | value, | |
| double | weight | |||
| ) | [inline, protected] |
Creates the initial bin in the histogram.
std::deque<double> glotzmath::DynamicHistogram< T >::mWeightOfBin [protected] |
Dynamic sized container holding the weight associated with each bin.
T glotzmath::DynamicHistogram< T >::mMin [protected] |
Minumum bound of the histogram.
T glotzmath::DynamicHistogram< T >::mMax [protected] |
Maximum bound of the histogram.
T glotzmath::DynamicHistogram< T >::mInc [protected] |
Increment of the histogram.
bool glotzmath::DynamicHistogram< T >::mIsFirstTime [protected] |
Indicates whether the first bin exists.
1.5.3