GClasses

GClasses::GHistogram Class Reference

Gathers values and puts them in bins. More...

#include <GHistogram.h>

List of all members.

Public Member Functions

 GHistogram (double min, double max, size_t binCount)
 This creates an empty histogram. You will need to call addSample To fill it with values.
 GHistogram (GMatrix &data, size_t col, double xmin=UNKNOWN_REAL_VALUE, double xmax=UNKNOWN_REAL_VALUE, size_t maxBuckets=10000000)
 Creates a histogram and fills it with values in the specified column of data. If xmin and/or xmax are UNKNOWN_REAL_VALUE, then it will determine a suitable range automatically. The number of buckets will be computed as min(maxBuckets,floor(sqrt(data.rows))).
 ~GHistogram ()
void addSample (double x, double weight=1.0)
 Adds a sample to the histogram.
size_t binCount ()
 Returns the number of bins in the histogram.
double binToX (size_t n)
 Returns the center (median) x-value represented by the specified binsum value in the specified bin.
size_t xToBin (double x)
 Returns the bin into which the specified value would fall. returns INVALID_INDEX if the value falls outside all of the bins.
double binProbability (size_t n)
 Returns the probability that a value falls in the specified bin.
double binLikelihood (size_t n)
 Returns the relative likelihood of the specified bin. (This is typically plotted as the height, or y-value for the specified bin.)
size_t modeBin ()
 Returns the index of the bin with the largest sum.
void toFile (const char *filename)
 Dumps to a file. You can then plot itwith GnuPlot or something similar.
double computeRange ()
 Returns the difference between the max and min likelihood values in the histogram.
double xmin ()
 Returns the minimum x value that will fall into one of the buckets.
double xmax ()
 Returns the maximum x value. That is, the value that will fall just beyond that greatest bucket.

Protected Attributes

double * m_bins
double m_sum
double m_min
double m_max
size_t m_binCount

Detailed Description

Gathers values and puts them in bins.


Constructor & Destructor Documentation

GClasses::GHistogram::GHistogram ( double  min,
double  max,
size_t  binCount 
)

This creates an empty histogram. You will need to call addSample To fill it with values.

GClasses::GHistogram::GHistogram ( GMatrix data,
size_t  col,
double  xmin = UNKNOWN_REAL_VALUE,
double  xmax = UNKNOWN_REAL_VALUE,
size_t  maxBuckets = 10000000 
)

Creates a histogram and fills it with values in the specified column of data. If xmin and/or xmax are UNKNOWN_REAL_VALUE, then it will determine a suitable range automatically. The number of buckets will be computed as min(maxBuckets,floor(sqrt(data.rows))).

GClasses::GHistogram::~GHistogram ( )

Member Function Documentation

void GClasses::GHistogram::addSample ( double  x,
double  weight = 1.0 
)

Adds a sample to the histogram.

size_t GClasses::GHistogram::binCount ( )

Returns the number of bins in the histogram.

double GClasses::GHistogram::binLikelihood ( size_t  n)

Returns the relative likelihood of the specified bin. (This is typically plotted as the height, or y-value for the specified bin.)

double GClasses::GHistogram::binProbability ( size_t  n)

Returns the probability that a value falls in the specified bin.

double GClasses::GHistogram::binToX ( size_t  n)

Returns the center (median) x-value represented by the specified binsum value in the specified bin.

double GClasses::GHistogram::computeRange ( )

Returns the difference between the max and min likelihood values in the histogram.

size_t GClasses::GHistogram::modeBin ( )

Returns the index of the bin with the largest sum.

void GClasses::GHistogram::toFile ( const char *  filename)

Dumps to a file. You can then plot itwith GnuPlot or something similar.

double GClasses::GHistogram::xmax ( ) [inline]

Returns the maximum x value. That is, the value that will fall just beyond that greatest bucket.

double GClasses::GHistogram::xmin ( ) [inline]

Returns the minimum x value that will fall into one of the buckets.

size_t GClasses::GHistogram::xToBin ( double  x)

Returns the bin into which the specified value would fall. returns INVALID_INDEX if the value falls outside all of the bins.


Member Data Documentation

double* GClasses::GHistogram::m_bins [protected]
double GClasses::GHistogram::m_max [protected]
double GClasses::GHistogram::m_min [protected]
double GClasses::GHistogram::m_sum [protected]