Visual Computing Library
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/math/histogram.h>

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

◆ binsNumber()

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

Number of intervals in the histogram.

Returns

◆ maxBinCount()

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

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

Returns

◆ maxBinCountInRange()

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

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

Returns

◆ maxRangeValue()

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

Maximum value of the range where the histogram is defined.

Returns

◆ maxValue()

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

Maximum value that has been added to the histogram.

Returns

◆ minRangeValue()

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

Minimum value of the range where the histogram is defined.

Returns

◆ minValue()

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

Minimum value that has been added to the histogram.

Returns

◆ numberValues()

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

Number of values inserted in the histogram.

Returns

◆ percentile()

template<typename ScalarType >
ScalarType vcl::Histogram< ScalarType >::percentile ( 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

◆ 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

◆ sumValues()

template<typename ScalarType >
ScalarType vcl::Histogram< ScalarType >::sumValues ( ) 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: