yat  0.21pre
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | Related Functions | List of all members
theplu::yat::statistics::Averager Class Reference

Class to calculate simple (first and second moments) averages. More...

#include <yat/statistics/Averager.h>

Inheritance diagram for theplu::yat::statistics::Averager:
theplu::yat::statistics::averager_base2< Averager > theplu::yat::statistics::averager_base< Averager >

Public Member Functions

 Averager (void)
 
 Averager (double x, double xx, long n)
 
 Averager (const Averager &a)
 
const Averageroperator= (const Averager &)
 The assignment operator.
 
template<class Derived >
const Averageroperator+= (const averager_base2< Derived > &other)
 plus assignment operator More...
 
double cv (void) const
 Coeffient of variation. More...
 
double standard_error (void) const
 
double std (void) const
 The standard deviation is defined as the square root of the variance. More...
 
double std (double m) const
 The standard deviation is defined as the square root of the variance. More...
 
double sum_xx (void) const
 
double sum_xx_centered (void) const
 
double variance (double m) const
 The variance with known mean. More...
 
double variance (void) const
 The estimated variance. More...
 
double variance_unbiased (void) const
 
void add (double x, long n=1)
 add a data point More...
 
double mean (void) const
 mean More...
 
long n (void) const
 number of data points More...
 
void rescale (double a)
 Rescales the object. More...
 
void reset (void)
 Reset object. More...
 
double sum_x (void) const
 

Protected Member Functions

void add2 (double mean, double cm2, long int n)
 
void add2 (double delta)
 
double rescale2 (double x)
 
void add1 (double x, long int n)
 
void add1 (double delta)
 
double rescale1 (double x)
 

Protected Attributes

double cm2_
 
long int n_
 
double mean_
 mean
 

Friends

class averager_base< Averager >
 

Related Functions

(Note that these are not member functions.)

template<typename InputIterator >
void add (Averager &a, InputIterator first, InputIterator last)
 adding a range of values to Averager a More...
 

Detailed Description

Class to calculate simple (first and second moments) averages.

See also
AveragerWeighted AveragerPair AveragerPairWeighted

Constructor & Destructor Documentation

◆ Averager() [1/3]

theplu::yat::statistics::Averager::Averager ( void  )

Default constructor

◆ Averager() [2/3]

theplu::yat::statistics::Averager::Averager ( double  x,
double  xx,
long  n 
)

Constructor taking sum of x, sum of squared x, xx, and number of samples n.

◆ Averager() [3/3]

theplu::yat::statistics::Averager::Averager ( const Averager a)

Copy constructor

Member Function Documentation

◆ add()

void theplu::yat::statistics::averager_base< Averager >::add ( double  x,
long  n = 1 
)
inlineinherited

add a data point

Adding n number of data point(s) with value x.

◆ add1() [1/2]

void theplu::yat::statistics::averager_base< Averager >::add1 ( double  x,
long int  n 
)
protectedinherited

add n data points with value x

◆ add1() [2/2]

void theplu::yat::statistics::averager_base< Averager >::add1 ( double  delta)
protectedinherited

add one data point with value delta + mean()

◆ add2() [1/2]

void theplu::yat::statistics::averager_base2< Averager >::add2 ( double  mean,
double  cm2,
long int  n 
)
protectedinherited

add a set of n data points with mean mean and centralized squaed sum cm

◆ add2() [2/2]

void theplu::yat::statistics::averager_base2< Averager >::add2 ( double  delta)
protectedinherited

add one data point with value delta + mean()

◆ cv()

double theplu::yat::statistics::averager_base2< Averager >::cv ( void  ) const
inlineinherited

Coeffient of variation.

Coeffient of variation (cv) is defined as ratio between the standard deviation and the mean: $ \frac{\sigma}{\mu} $.

Returns
standard deviation divided by mean.

◆ mean()

double theplu::yat::statistics::averager_base< Averager >::mean ( void  ) const
inlineinherited

mean

Returns
Mean of presented data, $ \frac{1}{n}\sum x_i $

◆ n()

long theplu::yat::statistics::averager_base< Averager >::n ( void  ) const
inlineinherited

number of data points

Returns
Number of data points

◆ operator+=()

template<class Derived >
const Averager & theplu::yat::statistics::Averager::operator+= ( const averager_base2< Derived > &  other)

plus assignment operator

Add another Averager

◆ rescale()

void theplu::yat::statistics::averager_base< Averager >::rescale ( double  a)
inlineinherited

Rescales the object.

$ \forall x_i \rightarrow a*x_i $,

◆ rescale1()

double theplu::yat::statistics::averager_base< Averager >::rescale1 ( double  x)
protectedinherited

rescale as $ mean \rightarrow x mean $

◆ rescale2()

double theplu::yat::statistics::averager_base2< Averager >::rescale2 ( double  x)
protectedinherited

rescales $ cm2 \rightarrow x^2 cm2 $ and calles rescale1(double)

◆ reset()

void theplu::yat::statistics::averager_base< Averager >::reset ( void  )
inlineinherited

Reset object.

Restore Averager as if data were never added

◆ standard_error()

double theplu::yat::statistics::averager_base2< Averager >::standard_error ( void  ) const
inlineinherited
Returns
Standard error, i.e. standard deviation of the mean $ \sqrt{variance()/n} $

◆ std() [1/2]

double theplu::yat::statistics::averager_base2< Averager >::std ( void  ) const
inlineinherited

The standard deviation is defined as the square root of the variance.

Returns
The standard deviation, root of the variance().

◆ std() [2/2]

double theplu::yat::statistics::averager_base2< Averager >::std ( double  m) const
inlineinherited

The standard deviation is defined as the square root of the variance.

Returns
Standard deviation around m, root of the variance(m).

◆ sum_x()

double theplu::yat::statistics::averager_base< Averager >::sum_x ( void  ) const
inlineinherited
Returns
The sum of data values

◆ sum_xx()

double theplu::yat::statistics::averager_base2< Averager >::sum_xx ( void  ) const
inlineinherited
Returns
The sum of squares

◆ sum_xx_centered()

double theplu::yat::statistics::averager_base2< Averager >::sum_xx_centered ( void  ) const
inlineinherited
Returns
$ \sum_i (x_i-m)^2 $

◆ variance() [1/2]

double theplu::yat::statistics::averager_base2< Averager >::variance ( double  m) const
inlineinherited

The variance with known mean.

The variance is calculated as $ \frac{1}{n}\sum (x_i-m)^2 $.

Returns
Variance when the mean is known to be m.

◆ variance() [2/2]

double theplu::yat::statistics::averager_base2< Averager >::variance ( void  ) const
inlineinherited

The estimated variance.

The variance is calculated as $ \frac{1}{N}\sum_i (x_i-m)^2 $, where $ m $ is the mean.

Returns
Estimation of variance

◆ variance_unbiased()

double theplu::yat::statistics::averager_base2< Averager >::variance_unbiased ( void  ) const
inlineinherited

The variance is calculated using the $ (n-1) $ correction, which means it is the best unbiased estimator of the variance $ \frac{1}{N-1}\sum_i (x_i-m)^2 $, where $ m $ is the mean.

Returns
unbiased estimation of variance

Friends And Related Function Documentation

◆ add()

template<typename InputIterator >
void add ( Averager a,
InputIterator  first,
InputIterator  last 
)
related

adding a range of values to Averager a

Type Requirements:

Member Data Documentation

◆ cm2_

double theplu::yat::statistics::averager_base2< Averager >::cm2_
protectedinherited

sum of values squared values centralized $ \sum (x-m)^2 $

◆ n_

long int theplu::yat::statistics::averager_base< Averager >::n_
protectedinherited

number of data points


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

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14