Visual Computing Library  devel
Loading...
Searching...
No Matches
vcl::Histogram< ScalarType > Class Template Reference

The Histogram class allows to collect a set of values and then compute some statistics like average, variance, standardDeviation, and percentiles. More...

#include <vclib/space/core/histogram.h>

Public Member Functions

void addValue (ScalarType value, ScalarType increment=1.0)
 Add a new value to the histogram.
 
ScalarType average () const
 Returns the average of the data.
 
uint binCount () const
 Number of intervals in the histogram.
 
ScalarType binLowerBound (uint ind) const
 
ScalarType binOfValueCount (ScalarType value) const
 
ScalarType binOfValueCount (ScalarType value, ScalarType width) const
 
ScalarType binOfValueWidth (ScalarType value)
 
ScalarType binUpperBound (uint ind) const
 
ScalarType binValuesCount (uint ind) const
 
ScalarType binValuesCountInRangeMax () const
 Max number of values among all bins between the minRangeValue and maxRangeValue.
 
ScalarType binValuesCountMax () const
 Max number of values among all bins (including the two infinity bounded bins)
 
void clear ()
 Clears the histogram.
 
 Histogram (ScalarType minRangeValue, ScalarType maxRangeValue, uint nBins, ScalarType gamma=1.0)
 Set the histogram values.
 
ScalarType rangeCount (ScalarType rangeMin, ScalarType rangeMax) const
 
ScalarType rangeValueMax () const
 Maximum value of the range where the histogram is defined.
 
ScalarType rangeValueMin () const
 Minimum value of the range where the histogram is defined.
 
ScalarType rootMeanSquare () const
 Returns the Root Mean Square of the data.
 
ScalarType standardDeviation () const
 Returns the standard deviation of the data.
 
ScalarType valueAtPercentile (ScalarType frac) const
 Returns the value corresponding to a given percentile of the data.
 
ScalarType valueCount () const
 Number of values inserted in the histogram.
 
ScalarType valueMax () const
 Maximum value that has been added to the histogram.
 
ScalarType valueMin () const
 Minimum value that has been added to the histogram.
 
ScalarType valueSum () const
 Total sum of inserted values.
 
ScalarType variance () const
 Returns the variance of the data.
 

Private Member Functions

uint binIndex (ScalarType elem) const
 Returns the index of the bin which contains a given element.
 

Private Attributes

uint mBinNumber = 0
 
ScalarType mCnt = 0
 
std::vector< ScalarType > mHist
 
ScalarType mMax = std::numeric_limits<ScalarType>::lowest()
 
ScalarType mMaxRange = 1
 
ScalarType mMin = std::numeric_limits<ScalarType>::max()
 
ScalarType mMinRange = 0
 
std::vector< ScalarType > mRanges
 
ScalarType mRMS = 0
 
ScalarType mSum = 0
 

Detailed Description

template<typename ScalarType>
class vcl::Histogram< ScalarType >

The Histogram class allows to collect a set of values and then compute some statistics like average, variance, standardDeviation, and percentiles.

Template Parameters
ScalarType

Constructor & Destructor Documentation

◆ Histogram()

template<typename ScalarType >
vcl::Histogram< ScalarType >::Histogram ( ScalarType  minRangeValue,
ScalarType  maxRangeValue,
uint  nBins,
ScalarType  gamma = 1.0 
)
inline

Set the histogram values.

This method is used to correctly initialize the bins of the histogram. n is the number of valid intervals between minv and maxv. for a more robust working, the Histogram class stores also the two out of range intervals (-inf, minv] and [maxv, +inf). Each bin is left closed (eg it contains the value). The gamma parameter is applied to modify the distribution of the ranges of the bins. Default uniform distribution.

Member Function Documentation

◆ addValue()

template<typename ScalarType >
void vcl::Histogram< ScalarType >::addValue ( ScalarType  value,
ScalarType  increment = 1.0 
)
inline

Add a new value to the histogram.

The statistics related to the histogram data (sum, RMS, etc.) are also updated.

◆ average()

template<typename ScalarType >
ScalarType vcl::Histogram< ScalarType >::average ( ) const
inline

Returns the average of the data.

Returns

◆ binCount()

template<typename ScalarType >
uint vcl::Histogram< ScalarType >::binCount ( ) const
inline

Number of intervals in the histogram.

Returns

◆ binValuesCountInRangeMax()

template<typename ScalarType >
ScalarType vcl::Histogram< ScalarType >::binValuesCountInRangeMax ( ) const
inline

Max number of values among all bins between the minRangeValue and maxRangeValue.

Returns

◆ binValuesCountMax()

template<typename ScalarType >
ScalarType vcl::Histogram< ScalarType >::binValuesCountMax ( ) const
inline

Max number of values among all bins (including the two infinity bounded bins)

Returns

◆ rangeValueMax()

template<typename ScalarType >
ScalarType vcl::Histogram< ScalarType >::rangeValueMax ( ) const
inline

Maximum value of the range where the histogram is defined.

Returns

◆ rangeValueMin()

template<typename ScalarType >
ScalarType vcl::Histogram< ScalarType >::rangeValueMin ( ) const
inline

Minimum value of the range where the histogram is defined.

Returns

◆ rootMeanSquare()

template<typename ScalarType >
ScalarType vcl::Histogram< ScalarType >::rootMeanSquare ( ) const
inline

Returns the Root Mean Square of the data.

Returns

◆ standardDeviation()

template<typename ScalarType >
ScalarType vcl::Histogram< ScalarType >::standardDeviation ( ) const
inline

Returns the standard deviation of the data.

Returns

◆ valueAtPercentile()

template<typename ScalarType >
ScalarType vcl::Histogram< ScalarType >::valueAtPercentile ( ScalarType  frac) const
inline

Returns the value corresponding to a given percentile of the data.

The percentile range between 0 and 1.

Parameters
frac
Returns

◆ valueCount()

template<typename ScalarType >
ScalarType vcl::Histogram< ScalarType >::valueCount ( ) const
inline

Number of values inserted in the histogram.

Returns

◆ valueMax()

template<typename ScalarType >
ScalarType vcl::Histogram< ScalarType >::valueMax ( ) const
inline

Maximum value that has been added to the histogram.

Returns

◆ valueMin()

template<typename ScalarType >
ScalarType vcl::Histogram< ScalarType >::valueMin ( ) const
inline

Minimum value that has been added to the histogram.

Returns

◆ valueSum()

template<typename ScalarType >
ScalarType vcl::Histogram< ScalarType >::valueSum ( ) const
inline

Total sum of inserted values.

Returns

◆ variance()

template<typename ScalarType >
ScalarType vcl::Histogram< ScalarType >::variance ( ) const
inline

Returns the variance of the data.

Returns

The documentation for this class was generated from the following file: