casacore
|
Makes a histogram from input values. More...
#include <HistAcc.h>
Public Member Functions | |
HistAcc (const uInt nBuff) | |
Constructors and destructor. More... | |
HistAcc (const uInt nBuff, const T width) | |
HistAcc (const T low, const T high, const T width) | |
HistAcc (const HistAcc &) | |
~HistAcc () | |
void | copy (const HistAcc &) |
Copy operations. More... | |
HistAcc & | operator= (const HistAcc &) |
void | put (const T v) |
Accumulate (put) value(s) into the histogram. More... | |
void | put (const Array< T > &vv) |
void | put (const Block< T > &vv) |
void | reset () |
Reset the contents of the bins to zero, but retain the current bin definition. More... | |
void | emptyBinsWithLessThan (const uInt nmin) |
Empty all bins whose contents is < nmin (e.g. More... | |
Fallible< T > | getPercentile (const Float p) |
The median is the 50-percentile (getPercentile(50)), i.e. More... | |
Fallible< T > | getMedian () |
Fallible< T > | getBinWidth () const |
All bins have the same width. More... | |
const StatAcc< T > & | getStatistics () |
Get the internal Statistics accumulator (see StatAcc,h). More... | |
Fallible< uInt > | getHistogram (Block< uInt > &bins, Block< T > &values) |
The return value is the nr of histogram bins, and is invalid if the number is zero. More... | |
uInt | getSpurious (uInt &tooSmall, uInt &tooLarge) |
Get the nr of `spurious' values, i.e. More... | |
void | printHistogram (ostream &, const String &caption) |
Print histogram. More... | |
Private Member Functions | |
void | put1 (const T) |
Accumulate a single value into the histogram. More... | |
void | defineBins (const T low, const T high, const T width) |
Definition of histogram bins with given parameters. More... | |
void | initBuffer (const uInt size) |
Internal helper functions for the automatic definition of histogram parameters, using the contents of itsBuffer. More... | |
void | putBuffer (const T v) |
void | clearBuffer () |
void | autoDefineBins () |
void | init () |
Other internal helper function(s). More... | |
Fallible< T > | getBinValue (const uInt index) const |
Private Attributes | |
Block< uInt > | itsBinContents |
Block< T > | itsBinHighLimit |
T | itsUserDefinedBinWidth |
StatAcc< T > | itsStatAcc |
Bool | itsAutoDefineMode |
Block< T > | itsBuffer |
uInt | itsBufferContents |
Makes a histogram from input values.
HistAcc stands for `Histogram Accumulator'.
Makes a histogram from input values. The histogram bin parameters may be defined, or determined from the first n input values. The input values are fed to HistAcc via the member function `put'. They can be fed individually, or in the form of an Array.
The histogram `bins' can be defined via the constructor in the form of loop variables: low bin, high bin, bin-width. It is also possible to let the bin parameters be determined automatically from the first n (e.g. n=50) input values. If the actual nr of input values is less than n when the histogram is interrogated in some way, the bin parameters will be determined from what is available.
It is usually convenient to let the bins be defined automatically:
In some cases the bin parameters are pre-defined:
The internal statistics accumulator can be interrogated explicitly or implicitly:
casacore::HistAcc< T >::HistAcc | ( | const uInt | nBuff | ) |
Constructors and destructor.
If the bin-parameters low, high and width (for lowest and highest bin, and binwidth) are not specified, they will be determined automatically from the first nBuff input values (which are stored in a temporary buffer).
casacore::HistAcc< T >::HistAcc | ( | const uInt | nBuff, |
const T | width | ||
) |
casacore::HistAcc< T >::HistAcc | ( | const T | low, |
const T | high, | ||
const T | width | ||
) |
casacore::HistAcc< T >::HistAcc | ( | const HistAcc< T > & | ) |
|
inline |
Definition at line 129 of file HistAcc.h.
References casacore::HistAcc< T >::copy(), casacore::HistAcc< T >::emptyBinsWithLessThan(), casacore::HistAcc< T >::getBinWidth(), casacore::HistAcc< T >::getHistogram(), casacore::HistAcc< T >::getMedian(), casacore::HistAcc< T >::getPercentile(), casacore::HistAcc< T >::getSpurious(), casacore::HistAcc< T >::getStatistics(), casacore::HistAcc< T >::operator=(), casacore::HistAcc< T >::printHistogram(), casacore::HistAcc< T >::put(), and casacore::HistAcc< T >::reset().
|
private |
|
private |
void casacore::HistAcc< T >::copy | ( | const HistAcc< T > & | ) |
Copy operations.
Referenced by casacore::HistAcc< T >::~HistAcc().
|
private |
Definition of histogram bins with given parameters.
void casacore::HistAcc< T >::emptyBinsWithLessThan | ( | const uInt | nmin | ) |
Empty all bins whose contents is < nmin (e.g.
nmin=2). This is useful to remove `noise' values from the histogram.
Referenced by casacore::HistAcc< T >::~HistAcc().
|
private |
Fallible<T> casacore::HistAcc< T >::getBinWidth | ( | ) | const |
All bins have the same width.
Referenced by casacore::HistAcc< T >::~HistAcc().
Fallible<uInt> casacore::HistAcc< T >::getHistogram | ( | Block< uInt > & | bins, |
Block< T > & | values | ||
) |
The return value is the nr of histogram bins, and is invalid if the number is zero.
The given blocks/vectors are resized, and contain the contents and centre values of the bins.
Referenced by casacore::HistAcc< T >::~HistAcc().
Fallible<T> casacore::HistAcc< T >::getMedian | ( | ) |
Referenced by casacore::HistAcc< T >::~HistAcc().
Fallible<T> casacore::HistAcc< T >::getPercentile | ( | const Float | p | ) |
The median is the 50-percentile (getPercentile(50)), i.e.
the value which has 50 percent of the input values below it. Calculation takes into account the spurious input values, i.e. values that fell outside the bins.
Referenced by casacore::HistAcc< T >::~HistAcc().
uInt casacore::HistAcc< T >::getSpurious | ( | uInt & | tooSmall, |
uInt & | tooLarge | ||
) |
Get the nr of `spurious' values, i.e.
the ones that fell outside the defined bins.
Referenced by casacore::HistAcc< T >::~HistAcc().
const StatAcc<T>& casacore::HistAcc< T >::getStatistics | ( | ) |
Get the internal Statistics accumulator (see StatAcc,h).
It can be used to obtain statistics of the input values.
Referenced by casacore::HistAcc< T >::~HistAcc().
|
private |
Other internal helper function(s).
|
private |
Internal helper functions for the automatic definition of histogram parameters, using the contents of itsBuffer.
HistAcc& casacore::HistAcc< T >::operator= | ( | const HistAcc< T > & | ) |
Referenced by casacore::HistAcc< T >::~HistAcc().
void casacore::HistAcc< T >::printHistogram | ( | ostream & | , |
const String & | caption | ||
) |
Print histogram.
Referenced by casacore::HistAcc< T >::~HistAcc().
|
inline |
Accumulate (put) value(s) into the histogram.
Definition at line 223 of file HistAcc.h.
References casacore::HistAcc< T >::put1().
Referenced by casacore::HistAcc< T >::~HistAcc().
void casacore::HistAcc< T >::put | ( | const Array< T > & | vv | ) |
void casacore::HistAcc< T >::put | ( | const Block< T > & | vv | ) |
|
private |
Accumulate a single value into the histogram.
Referenced by casacore::HistAcc< T >::put().
|
private |
void casacore::HistAcc< T >::reset | ( | ) |
Reset the contents of the bins to zero, but retain the current bin definition.
Referenced by casacore::HistAcc< T >::~HistAcc().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |