TSDuck v3.38-3699
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT, class > Class Template Reference

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

#include <tsSingleDataStatistics.h>

Public Types

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

Public Member Functions

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

Detailed Description

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

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

Template Parameters
NUMBERInteger or floating point data type. A specialization is available for std::chrono::duration types.
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 , class N >
void ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT, N >::feed ( NUMBER  value)

Accumulate one more data sample.

Parameters
[in]valueData sample.

◆ count()

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

Get the number of accumulated samples.

Returns
The number of accumulated samples.

◆ minimum()

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

Get the minimum value of all accumulated samples.

Returns
The minimum value.

◆ maximum()

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

Get the maximum value of all accumulated samples.

Returns
The maximum value.

◆ mean()

template<typename NUMBER , typename DEFAULT_FLOAT , class N >
ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT, N >::FLOAT ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT, N >::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, class = void>
NUMBER ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT, class >::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 , class N >
ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT, N >::FLOAT ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT, N >::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, class = void>
FLOAT ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT, class >::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 , class N >
ts::UString ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT, N >::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 , class N >
ts::UString ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT, N >::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 , class N >
ts::UString ts::SingleDataStatistics< NUMBER, DEFAULT_FLOAT, N >::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: