Biorithm  1.1
Public Member Functions
MyHistogram Class Reference

A simple class to create and manipulate histograms. More...

#include <histogram.h>

List of all members.

Public Member Functions

 MyHistogram (unsigned int numBins=10, MyNT low=0, MyNT high=1)
virtual ~MyHistogram ()
virtual MyNT computeMean ()
virtual MyNT computeStandardDeviation (MyNT mean)
virtual MyNT computeVariance (MyNT mean)
virtual unsigned int getNumBins () const
virtual MyNT getBin (MyNT coord) const
 Return the lower bound of the bin containing the argument.
virtual void setBin (MyNT coord, MyNT value)
 Set the bin corresponding to coord to contain the argument value.
virtual MyNT getValue (MyNT coord) const
 Return the value in the bin corresponding to coord.
MyNT getMin () const
MyNT getMax () const
MyNT getRange () const
virtual void insert (MyNT value)
virtual void insert (const vector< MyNT > &values)
virtual void insert (const vector< unsigned int > &values)
virtual void abs ()
virtual void accumulate (bool reverse=false)
void constructTDistributionHistogram (unsigned int dof)
virtual MyNT convertToPvalues (MyNT pvalueThreshold=0.01, LIBENRICHMENT_TEST_TYPE testType=LIBENRICHMENT_NONE, MyHistogram *reference=NULL)
 Convert the values in the histogram into p-values by normalising and computing the cumulative distribution.
virtual void convertToPvalues (MyNT pvalueThreshold, const set< LIBENRICHMENT_TEST_TYPE > &testTypes, map< LIBENRICHMENT_TEST_TYPE, MyNT > &thresholds, map< LIBENRICHMENT_TEST_TYPE, MyHistogram > &histograms, MyHistogram *reference=NULL)
 Convert the values in the histogram into p-values by normalising and computing the cumulative distribution. Use each test in testTypes to correct for multiple hypotheses testing.
virtual const MyHistogramoperator= (const MyHistogram &other)
virtual MyHistogram operator+ (const MyHistogram &other)
virtual MyHistogram operator- (MyNT weight)
virtual MyHistogram operator- ()
virtual const MyHistogramoperator+= (const MyHistogram &other)
virtual MyHistogram operator* (MyNT weight)
 Return a new histogram where each bin is the product of each bin in this histogram and weight.
virtual void operator*= (MyNT weight)
virtual MyHistogram operator/ (MyHistogram &other)
virtual const MyHistogramoperator/= (MyHistogram &other)
virtual void normalise ()
virtual MyNT getNumTotalValues () const
virtual void print (ostream &ostr, string extra="", vector< MyHistogram > *others=NULL)
virtual void print (string file, string extra="", vector< MyHistogram > *others=NULL)
virtual void read (string infile)
virtual double computeTrapezoidalAUC (const MyHistogram &other) const

Detailed Description

A simple class to create and manipulate histograms.

Author:
T. M. Murali (murali@cs.vt.edu). A class to create and manipulate histograms.

Constructor & Destructor Documentation

MyHistogram::MyHistogram ( unsigned int  numBins = 10,
MyNT  low = 0,
MyNT  high = 1 
) [inline]

The constructor.

Parameters:
unsignedint numBins, the number of bins in the histogram. The default value is 10.
MyNTlow, the smallest value to be stored in the histogram. The default value is 0.
MyNThigh, the largest value to be stored in the histogram. The default value is 1.
Remarks:
The class does not provide any other way to set the limits of the histogram, so as to prevent changing the limits after some values have been inserted into this histogram.
virtual MyHistogram::~MyHistogram ( ) [inline, virtual]

The destructor.


Member Function Documentation

void MyHistogram::abs ( ) [virtual]

Compute the absolute value of the histogram.

For every bin with a negative

void MyHistogram::accumulate ( bool  reverse = false) [virtual]

Set the value of each bin to be the partial sum of all the values in earlier bins.

Parameters:
[in]reverse,aboolean; if true, compute the partial sum in reverse.

This method is useful for converting a normalised histogram into a histogram of p-values, or with reverse set to true, into a histogram of probabilities.

MyNT MyHistogram::computeMean ( ) [virtual]

Compute the mean of the values stored in the histogram.

The method approximates each value stored by the lower endpoint of the bin the value falls in.

MyNT MyHistogram::computeStandardDeviation ( MyNT  mean) [virtual]

Compute the standard deviation of the values stored in the histogram.

Parameters:
in[mean, the result of invoking MyHistogram::computeMean() on the invocant.

The method approximates each value stored by the lower endpoint of the bin the value falls in.

MyNT MyHistogram::computeVariance ( MyNT  mean) [virtual]

Compute the variance of the values stored in the histogram.

Parameters:
in[mean, the result of invoking MyHistogram::computeMean() on the invocant.

The method approximates each value stored by the lower endpoint of the bin the value falls in.

Fill the histogram with values of the tail of Student's t distribution with dof degrees of freedom.

Parameters:
[in]dof,thenumber of degrees of freedom of the t distribution.

For each bin in the histogram, the method calculates the value of the (tail of the) t distribution at the left endpoint of the bin and stores that value in the bin.

MyNT MyHistogram::getMax ( ) const [inline]

Return the maximum value to be stored in the histogram.

MyNT MyHistogram::getMin ( ) const [inline]

Return the minimum value to be stored in the histogram.

virtual unsigned int MyHistogram::getNumBins ( ) const [inline, virtual]

Return the number of bins

virtual MyNT MyHistogram::getNumTotalValues ( ) const [inline, virtual]

Return the total number of values stored in the histogram.

MyNT MyHistogram::getRange ( ) const [inline]

Return the range of values to be stored in the histogram.

void MyHistogram::insert ( MyNT  value) [virtual]

Insert a value into to the histogram.

void MyHistogram::insert ( const vector< MyNT > &  values) [virtual]

Insert a vector of values into the histogram.

Insert a value into to the histogram. If value is less than min(), store value in the smallest bin. If value is larger than max(), store value in the largest bin.

Parameters:
MyNTvalue, the number to be inserted.
void MyHistogram::normalise ( ) [virtual]

Ensure that the total number of values over all the bins is 1. The method simply divides the value in each bin by the total number of values in all the bins.

Note:
This method is equivalent to invoking MyHistogram::operator*() with the argument getNumTotalValues().
void MyHistogram::operator*= ( MyNT  weight) [virtual]

Multiply each bin in this histogram by weight.

Parameters:
[in]weight,thenumber to multiply each bin by.
MyHistogram MyHistogram::operator+ ( const MyHistogram other) [virtual]

Add two histograms.

Add other histogram to this histogram and return a new histogram containing the sum.

Warning:
Both histograms must have identical bins.
Parameters:
MyHistogramother, the other histogram to be added to the invocant.
Returns:
A MyHistogram containing the sum of the two histograms.
const MyHistogram & MyHistogram::operator+= ( const MyHistogram other) [virtual]

Increment invocant by another histogram.

Increment invocant by another histogram.

Warning:
Both histograms must have identical bins.
Parameters:
MyHistogramother, the other histogram to be added to the invocant.
MyHistogram MyHistogram::operator- ( MyNT  weight) [virtual]

Subtract a number from the histogram.

MyHistogram MyHistogram::operator- ( ) [virtual]

Negate a number from the histogram.

MyHistogram MyHistogram::operator/ ( MyHistogram other) [virtual]

Create a new histogram by dividing the value in each bin in this histogram by the value in the bin in other.

Warning:
The behaviour of this method is undefined if the invocant and other do not have exactly the same range and number of bins.
const MyHistogram & MyHistogram::operator/= ( MyHistogram other) [virtual]

Dividing the value in each bin in this histogram by the value in the bin in other.

Warning:
The behaviour of this method is undefined if the invocant and other do not have exactly the same range and number of bins.
const MyHistogram & MyHistogram::operator= ( const MyHistogram other) [virtual]

Set the invocant equal to other.

Set invocant equal to another histogram.

Parameters:
MyHistogramother, the other histogram that the invocant will equal.
void MyHistogram::print ( ostream &  ostr,
string  extra = "",
vector< MyHistogram > *  others = NULL 
) [virtual]

Print the histogram.

Parameters:
[in]ostr,areference to an output stream.
[in]extra,an"extra" string to print at the beginning of the output. Usually, this string is a comment. If you want to the output file to be processed by a plotting programme such as gnuplot, make sure that the extra string starts with a comment character, e.g., '#'.
[in]otherHistograms,apointer to a vector of MyHistograms to print "in parallel" to the invocant.
Warning:
The method assumes that all histograms have the same limits and number of bins.
void MyHistogram::print ( string  file,
string  extra = "",
vector< MyHistogram > *  others = NULL 
) [virtual]

Print the histogram

Print the histogram to an output stream.

Parameters:
[in]file,astring specifying the file to print the histogram to.
[in]extra,an"extra" string to print at the beginning of the output. Usually, this string is a comment. If you want to the output file to be processed by a plotting programme such as gnuplot, make sure that the extra string starts with a comment character, e.g., '#'.
[in]otherHistograms,apointer to a vector of MyHistograms to print "in parallel" to the invocant.
Warning:
The method assumes that all histograms have the same limits and number of bins.
void MyHistogram::read ( string  infile) [virtual]

Read the histogram from a file containing bin-value pairs.

The method assumes that blank lines separate different histograms.

Warning:
The behaviour of this method is undefined if infile contains multiple histograms with different ranges or differing number of bins.

The documentation for this class was generated from the following files:
 All Classes Functions Variables Typedefs Friends