#include <Histogram.h>
Public Member Functions | |
Histogram () | |
Constructor, making an undefined histogram. | |
Histogram (double min, double max, int num_bins) | |
Constructor which explicitly defines the range and number of histogram bins. | |
void | init (double min, double max, int num_bins) |
Initialize an already-existing Histogram with a new range and number of bins. | |
int | numBins () const |
get the total number of bins in the Histogram | |
double | rangeMin () const |
get the lower bound of the Histogram's value range | |
double | rangeMax () const |
get the upper bound of the Histogram's value range | |
std::vector< double > & | binValues () |
void | blur (double sigma) |
blur the histogram | |
int | getBin (double val) const |
Get the index of the appropriate bin for a given value. | |
double | valueFor (double val) const |
Get the "histogram value" for a given value in the Histogram's range. | |
void | write (std::ostream &os) const |
write the complete Histogram object to a stream | |
void | read (std::istream &is) |
read the complete Histogram object from a stream | |
Private Attributes | |
double | range_min_ |
defines the lower bound on the continous value range | |
double | range_max_ |
definies the upper bound on the continuous value range | |
double | bin_factor_ |
expresses the "width" of each bin | |
std::vector< double > | dist_ |
STL vector holding the value of each individual bin's contents. |
A histogram class, representing the distribution of a continuous range of values into a discrete set of bins.
Definition at line 65 of file Histogram.h.
lsseg::Histogram::Histogram | ( | ) | [inline] |
Constructor, making an undefined histogram.
The constructed Histogram is useless, but can be initialized using the init() function.
Definition at line 73 of file Histogram.h.
lsseg::Histogram::Histogram | ( | double | min, | |
double | max, | |||
int | num_bins | |||
) | [inline] |
Constructor which explicitly defines the range and number of histogram bins.
Upon successful construction, the bins will all be empty.
min | lower bound of the continuous value range that should be split up into discrete bins | |
max | upped bound of the continuous value range that should be split up into discrete bins | |
num_bins | number of discrete bins of this histogram. |
Definition at line 84 of file Histogram.h.
std::vector<double>& lsseg::Histogram::binValues | ( | ) | [inline] |
Definition at line 113 of file Histogram.h.
void lsseg::Histogram::blur | ( | double | sigma | ) |
blur the histogram
The contents of the histogram's bins will be "smoothed" with a factor determined by the argument sigma
. (sigma
is a positive value - and higher values will result in more smoothing).
Definition at line 100 of file Histogram.C.
int lsseg::Histogram::getBin | ( | double | val | ) | const |
Get the index of the appropriate bin for a given value.
val | the value for which we want the correct bin index. It is supposed that val is within the continuous value range, which is the closed interval defined by rangeMin() and rangeMax(). |
Definition at line 91 of file Histogram.C.
void lsseg::Histogram::init | ( | double | min, | |
double | max, | |||
int | num_bins | |||
) | [inline] |
Initialize an already-existing Histogram with a new range and number of bins.
min | lower bound of the continuous value range that should be split up into discrete bins | |
max | upped bound of the continuous value range that should be split up into discrete bins | |
num_bins | number of discrete bins of this histogram. |
Definition at line 97 of file Histogram.h.
int lsseg::Histogram::numBins | ( | ) | const [inline] |
double lsseg::Histogram::rangeMax | ( | ) | const [inline] |
double lsseg::Histogram::rangeMin | ( | ) | const [inline] |
void lsseg::Histogram::read | ( | std::istream & | is | ) |
double lsseg::Histogram::valueFor | ( | double | val | ) | const |
Get the "histogram value" for a given value in the Histogram's range.
The "histogram value" is a value we have defined to be the product of the value of the bin in which the argment val
falls, multiplied by the width of the bin.
Definition at line 107 of file Histogram.C.
void lsseg::Histogram::write | ( | std::ostream & | os | ) | const |
double lsseg::Histogram::bin_factor_ [private] |
std::vector<double> lsseg::Histogram::dist_ [private] |
STL vector holding the value of each individual bin's contents.
Definition at line 155 of file Histogram.h.
double lsseg::Histogram::range_max_ [private] |
double lsseg::Histogram::range_min_ [private] |