BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlsta::Moment< ML > Class Template Reference

#include <bdlsta_moment.h>

Public Types

enum  { e_SUCCESS = 0 , e_INADEQUATE_DATA = -1 }
 

Public Member Functions

void add (double value)
 Add the specified value to the data set.
 
int count () const
 Returns the number of elements in the data set.
 
double kurtosis () const
 
int kurtosisIfValid (double *result) const
 
double mean () const
 
int meanIfValid (double *result) const
 
double skew () const
 
int skewIfValid (double *result) const
 
double variance () const
 
int varianceIfValid (double *result) const
 
void add (double value)
 
void add (double value)
 
void add (double value)
 
void add (double value)
 
double kurtosis () const
 
int kurtosisIfValid (double *result) const
 

Detailed Description

template<MomentLevel::Enum ML>
class bdlsta::Moment< ML >

This class provides efficient and accurate online algorithms for calculating mean, variance, skew, and kurtosis. The class provides template specializations, so that no unnecessary data members will be kept or unnecessary calculations done. The online algorithms used are Welford for variance, and the stable M3 and M4 are taken from: https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Higher-order_statistics

The formula for sample skewness is taken from: http://www.macroption.com/skewness-formula/

The formula for sample excess kurtosis is taken from: http://www.macroption.com/kurtosis-formula/

See bdlsta_moment

Member Enumeration Documentation

◆ anonymous enum

template<MomentLevel::Enum ML>
anonymous enum
Enumerator
e_SUCCESS 
e_INADEQUATE_DATA 

Member Function Documentation

◆ add() [1/5]

template<MomentLevel::Enum ML>
void bdlsta::Moment< ML >::add ( double  value)

◆ add() [2/5]

void bdlsta::Moment< MomentLevel::e_M1 >::add ( double  value)
inline

◆ add() [3/5]

void bdlsta::Moment< MomentLevel::e_M2 >::add ( double  value)
inline

◆ add() [4/5]

void bdlsta::Moment< MomentLevel::e_M3 >::add ( double  value)
inline

◆ add() [5/5]

void bdlsta::Moment< MomentLevel::e_M4 >::add ( double  value)
inline

◆ count()

template<MomentLevel::Enum ML>
int bdlsta::Moment< ML >::count ( ) const
inline

◆ kurtosis() [1/2]

template<MomentLevel::Enum ML>
double bdlsta::Moment< ML >::kurtosis ( ) const

Return the kurtosis of the data set. The behavior is undefined unless 4 <= count and the variance is not zero.

◆ kurtosis() [2/2]

double bdlsta::Moment< MomentLevel::e_M4 >::kurtosis ( ) const
inline

◆ kurtosisIfValid() [1/2]

template<MomentLevel::Enum ML>
int bdlsta::Moment< ML >::kurtosisIfValid ( double *  result) const

Load into the specified result, the kurtosis of the data set. Return 0 on success, and a non-zero value otherwise. Specifically, e_INADEQUATE_DATA is returned if 4 > count or the variance is zero.

◆ kurtosisIfValid() [2/2]

int bdlsta::Moment< MomentLevel::e_M4 >::kurtosisIfValid ( double *  result) const
inline

◆ mean()

template<MomentLevel::Enum ML>
double bdlsta::Moment< ML >::mean ( ) const
inline

Return the mean of the data set. The behavior is undefined unless 1 <= count.

◆ meanIfValid()

template<MomentLevel::Enum ML>
int bdlsta::Moment< ML >::meanIfValid ( double *  result) const
inline

Load into the specified result, the mean of the data set. Return 0 on success, and a non-zero value otherwise. Specifically, e_INADEQUATE_DATA is returned if 1 > count.

◆ skew()

template<MomentLevel::Enum ML>
double bdlsta::Moment< ML >::skew ( ) const
inline

Return skew of the data set. The behavior is undefined unless 3 <= count or the variance is zero.

◆ skewIfValid()

template<MomentLevel::Enum ML>
int bdlsta::Moment< ML >::skewIfValid ( double *  result) const
inline

Load into the specified result, the skew of the data set. Return 0 on success, and a non-zero value otherwise. Specifically, e_INADEQUATE_DATA is returned if 3 > count or the variance is zero.

◆ variance()

template<MomentLevel::Enum ML>
double bdlsta::Moment< ML >::variance ( ) const
inline

Return the variance of the data set. The behavior is undefined unless 2 <= count.

◆ varianceIfValid()

template<MomentLevel::Enum ML>
int bdlsta::Moment< ML >::varianceIfValid ( double *  result) const
inline

Load into the specified result, the variance of the data set. Return 0 on success, and a non-zero value otherwise. Specifically, e_INADEQUATE_DATA is returned if 2 > count.


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