Biorithm
1.1
|
A simple class to create and manipulate histograms. More...
#include <histogram.h>
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 MyHistogram & | operator= (const MyHistogram &other) |
virtual MyHistogram | operator+ (const MyHistogram &other) |
virtual MyHistogram | operator- (MyNT weight) |
virtual MyHistogram | operator- () |
virtual const MyHistogram & | operator+= (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 MyHistogram & | operator/= (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 |
A simple class to create and manipulate histograms.
MyHistogram::MyHistogram | ( | unsigned int | numBins = 10 , |
MyNT | low = 0 , |
||
MyNT | high = 1 |
||
) | [inline] |
The constructor.
unsigned | int numBins, the number of bins in the histogram. The default value is 10. |
MyNT | low, the smallest value to be stored in the histogram. The default value is 0. |
MyNT | high, the largest value to be stored in the histogram. The default value is 1. |
virtual MyHistogram::~MyHistogram | ( | ) | [inline, virtual] |
The destructor.
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.
[in] | reverse,a | boolean; 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.
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.
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.
void MyHistogram::constructTDistributionHistogram | ( | unsigned int | dof | ) |
Fill the histogram with values of the tail of Student's t distribution with dof degrees of freedom.
[in] | dof,the | number 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.
MyNT | value, 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.
void MyHistogram::operator*= | ( | MyNT | weight | ) | [virtual] |
Multiply each bin in this histogram by weight.
[in] | weight,the | number 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.
MyHistogram | other, the other histogram to be added to the invocant. |
const MyHistogram & MyHistogram::operator+= | ( | const MyHistogram & | other | ) | [virtual] |
Increment invocant by another histogram.
Increment invocant by another histogram.
MyHistogram | other, 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.
const MyHistogram & MyHistogram::operator/= | ( | MyHistogram & | other | ) | [virtual] |
Dividing the value in each bin in this histogram by the value in the bin in other.
const MyHistogram & MyHistogram::operator= | ( | const MyHistogram & | other | ) | [virtual] |
Set the invocant equal to other.
Set invocant equal to another histogram.
MyHistogram | other, the other histogram that the invocant will equal. |
void MyHistogram::print | ( | ostream & | ostr, |
string | extra = "" , |
||
vector< MyHistogram > * | others = NULL |
||
) | [virtual] |
Print the histogram.
[in] | ostr,a | reference 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,a | pointer to a vector of MyHistograms to print "in parallel" to the invocant. |
void MyHistogram::print | ( | string | file, |
string | extra = "" , |
||
vector< MyHistogram > * | others = NULL |
||
) | [virtual] |
Print the histogram
Print the histogram to an output stream.
[in] | file,a | string 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,a | pointer to a vector of MyHistograms to print "in parallel" to the invocant. |
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.