glotzmath::DynamicHistogram< T > Class Template Reference
[Math]

A dynamically sized histogram. More...

#include <DynamicHistogram.h>

List of all members.

Public Member Functions

 DynamicHistogram ()
 Default constructor.
 DynamicHistogram (T inc)
 Default constructor taking bin increment.
 DynamicHistogram (const DynamicHistogram &rhs)
 Copy constructor.
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.
mMin
 Minumum bound of the histogram.
mMax
 Maximum bound of the histogram.
mInc
 Increment of the histogram.
bool mIsFirstTime
 Indicates whether the first bin exists.


Detailed Description

template<class T>
class glotzmath::DynamicHistogram< T >

A dynamically sized histogram.

Author:
Aaron Keys
        #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
        }

Member Enumeration Documentation

template<class T>
anonymous enum [protected]

Enumerator:
TOO_SMALL 
TOO_BIG 


Constructor & Destructor Documentation

template<class T>
glotzmath::DynamicHistogram< T >::DynamicHistogram (  )  [inline]

Default constructor.

template<class T>
glotzmath::DynamicHistogram< T >::DynamicHistogram ( inc  )  [inline]

Default constructor taking bin increment.

template<class T>
glotzmath::DynamicHistogram< T >::DynamicHistogram ( const DynamicHistogram< T > &  rhs  )  [inline]

Copy constructor.


Member Function Documentation

template<class T>
T glotzmath::DynamicHistogram< T >::GetBinSize (  )  const [inline]

Returns the size of each bin.

template<class T>
void glotzmath::DynamicHistogram< T >::CombineWith ( const DynamicHistogram< T > &  rhs  )  [inline]

Addition function.

template<class T>
void glotzmath::DynamicHistogram< T >::SetBinSize ( size  )  [inline]

Sets the bin size.

template<class T>
double& glotzmath::DynamicHistogram< T >::operator[] ( int  i  )  [inline]

Indexing operator.

template<class T>
void glotzmath::DynamicHistogram< T >::Insert ( value  )  [inline]

Inserts a datapoint into the histogram is the value to be inserted.

template<class T>
void glotzmath::DynamicHistogram< T >::Insert ( value,
double  weight 
) [inline]

Inserts a datapoint into the histogram is the value to be inserted is the weight of the datapoint.

template<class T>
void glotzmath::DynamicHistogram< T >::Clear (  )  [inline]

Clears the contents of the histogram.

See also:
Reset()

template<class T>
void glotzmath::DynamicHistogram< T >::Reset (  )  [inline]

Clears the contents of the histogram.

See also:
Clear()

template<class T>
void glotzmath::DynamicHistogram< T >::Print (  )  [inline]

Prints the histogram to stdout.

template<class T>
void glotzmath::DynamicHistogram< T >::Print ( std::ostream &  os  )  [inline]

Prints the histogram to a stream is the stream to print to.

template<class T>
unsigned int glotzmath::DynamicHistogram< T >::GetNumberOfBins (  )  const [inline]

Returns the number of bins in the histogram.

template<class T>
std::pair<T, T> glotzmath::DynamicHistogram< T >::GetBin ( unsigned int  i  )  [inline]

Returns the number of bins in the histogram.

template<class T>
std::pair<T, T> glotzmath::DynamicHistogram< T >::Max (  )  [inline]

template<class T>
void glotzmath::DynamicHistogram< T >::ExpandRight ( 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.

template<class T>
void glotzmath::DynamicHistogram< T >::ExpandLeft ( 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.

template<class T>
int glotzmath::DynamicHistogram< T >::ComputeBinContaining ( value  )  [inline, protected]

Computes the bin number containing a given datapoint is the value of the datapoint.

template<class T>
void glotzmath::DynamicHistogram< T >::CreateFirstBin ( value,
double  weight 
) [inline, protected]

Creates the initial bin in the histogram.


Member Data Documentation

template<class T>
std::deque<double> glotzmath::DynamicHistogram< T >::mWeightOfBin [protected]

Dynamic sized container holding the weight associated with each bin.

template<class T>
T glotzmath::DynamicHistogram< T >::mMin [protected]

Minumum bound of the histogram.

template<class T>
T glotzmath::DynamicHistogram< T >::mMax [protected]

Maximum bound of the histogram.

template<class T>
T glotzmath::DynamicHistogram< T >::mInc [protected]

Increment of the histogram.

template<class T>
bool glotzmath::DynamicHistogram< T >::mIsFirstTime [protected]

Indicates whether the first bin exists.


The documentation for this class was generated from the following file:
Generated on Tue Feb 24 20:53:39 2009 by  doxygen 1.5.3