TSDuck Version 3.32-2769 (TSDuck - The MPEG Transport Stream Toolkit)
ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT > Class Template Reference

Statistics over a single set of data (integer or floating point). More...

Public Types

typedef std::conditional< std::is_floating_point< NUMBER >::value, NUMBER, DEFAULT_FLOAT >::type FLOAT
 The floating-point type for NUMBER finer results.
 
typedef ts::make_signed< NUMBER >::type SIGNED
 The signed type for NUMBER.
 

Public Member Functions

 SingleDataStatistics ()
 Constructor.
 
size_t count () const
 Get the number of accumulated samples. More...
 
void feed (NUMBER value)
 Accumulate one more data sample. More...
 
NUMBER maximum () const
 Get the maximum value of all accumulated samples. More...
 
FLOAT mean () const
 Get the mean value of all accumulated samples. More...
 
NUMBER meanRound () const
 Get the mean value of all accumulated samples, rounded to the nearest integer. More...
 
UString meanString (size_t width=0, size_t precision=2) const
 Get the mean value of all accumulated samples as a string. More...
 
NUMBER minimum () const
 Get the minimum value of all accumulated samples. More...
 
void reset ()
 Reset the statistics collection.
 
FLOAT standardDeviation () const
 Get the standard deviation of all accumulated samples. More...
 
UString standardDeviationString (size_t width=0, size_t precision=2) const
 Get the standard deviation of all accumulated samples as a string. More...
 
FLOAT variance () const
 Get the variance of all accumulated samples. More...
 
UString varianceString (size_t width=0, size_t precision=2) const
 Get the variance of all accumulated samples as a string. More...
 

Detailed Description

template<typename NUMBER, typename DEFAULT_FLOAT = double>
class ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT >

Statistics over a single set of data (integer or floating point).

Template Parameters
NUMBERInteger or floating point data type.
DEFAULT_FLOATDefault floating point type for finer results. Ignored if NUMBER is a floating point type.

Member Function Documentation

◆ feed()

template<typename NUMBER , typename DEFAULT_FLOAT = double>
void ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT >::feed ( NUMBER  value)

Accumulate one more data sample.

Parameters
[in]valueData sample.

◆ count()

template<typename NUMBER , typename DEFAULT_FLOAT = double>
size_t ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT >::count ( ) const
inline

Get the number of accumulated samples.

Returns
The number of accumulated samples.

◆ minimum()

template<typename NUMBER , typename DEFAULT_FLOAT = double>
NUMBER ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT >::minimum ( ) const
inline

Get the minimum value of all accumulated samples.

Returns
The minimum value.

◆ maximum()

template<typename NUMBER , typename DEFAULT_FLOAT = double>
NUMBER ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT >::maximum ( ) const
inline

Get the maximum value of all accumulated samples.

Returns
The maximum value.

◆ mean()

template<typename NUMBER , typename DEFAULT_FLOAT = double>
FLOAT ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT >::mean ( ) const

Get the mean value of all accumulated samples.

Returns
The mean value. When NUMBER is an integer type, the returned value is from the FLOAT floating-point type.

◆ meanRound()

template<typename NUMBER , typename DEFAULT_FLOAT = double>
NUMBER ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT >::meanRound ( ) const
inline

Get the mean value of all accumulated samples, rounded to the nearest integer.

Returns
The mean value, rounded to the nearest integer.

◆ variance()

template<typename NUMBER , typename DEFAULT_FLOAT = double>
FLOAT ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT >::variance ( ) const

Get the variance of all accumulated samples.

Returns
The variance. When NUMBER is an integer type, the returned value is from the FLOAT floating-point type.

◆ standardDeviation()

template<typename NUMBER , typename DEFAULT_FLOAT = double>
FLOAT ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT >::standardDeviation ( ) const
inline

Get the standard deviation of all accumulated samples.

Returns
The standard deviation. When NUMBER is an integer type, the returned value is from the FLOAT floating-point type.

◆ meanString()

template<typename NUMBER , typename DEFAULT_FLOAT = double>
UString ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT >::meanString ( size_t  width = 0,
size_t  precision = 2 
) const

Get the mean value of all accumulated samples as a string.

Parameters
[in]widthMinimum width of the string, left-padded with spaces.
[in]precisionNumber of decimal digits.
Returns
The mean value as a string.

◆ varianceString()

template<typename NUMBER , typename DEFAULT_FLOAT = double>
UString ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT >::varianceString ( size_t  width = 0,
size_t  precision = 2 
) const

Get the variance of all accumulated samples as a string.

Parameters
[in]widthMinimum width of the string, left-padded with spaces.
[in]precisionNumber of decimal digits.
Returns
The variance as a string.

◆ standardDeviationString()

template<typename NUMBER , typename DEFAULT_FLOAT = double>
UString ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT >::standardDeviationString ( size_t  width = 0,
size_t  precision = 2 
) const

Get the standard deviation of all accumulated samples as a string.

Parameters
[in]widthMinimum width of the string, left-padded with spaces.
[in]precisionNumber of decimal digits.
Returns
The standard deviation as a string.

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