yat  0.20.3pre
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
theplu::yat::statistics::averager_base< Derived > Class Template Referenceabstract

Base class for averager classes. More...

#include <yat/statistics/averager_base.h>

Inheritance diagram for theplu::yat::statistics::averager_base< Derived >:
theplu::yat::statistics::averager_base2< Derived > theplu::yat::statistics::averager_base3< Derived > theplu::yat::statistics::averager_base4< Derived >

Public Member Functions

 averager_base (void)
 Constructor.
 
virtual ~averager_base (void)=0
 Destructor.
 
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 add1 (double x, long int n)
 
void add1 (double delta)
 
double rescale1 (double x)
 

Protected Attributes

long int n_
 
double mean_
 mean
 

Detailed Description

template<class Derived>
class theplu::yat::statistics::averager_base< Derived >

Base class for averager classes.

This is a base class templated on the derived class (see curiously recurring template pattern), which implies there is no dynamic polymorphism but the concrete type must be decided at compile time.

The derived class, MyClass, needs to have the following features:

These two functions need to be public or if you dont want to expose them to the world, make them private and declare averager_base<Derived> as friend.

A derived class is typically declared as

class MyClass : public averager_base<MyClass>
{
...
private:
friend class averager_base<MyClass>;
void add_impl(double, long int);
void rescale_impl(double);
};
Since
yat 0.9

Member Function Documentation

◆ add()

template<class Derived>
void theplu::yat::statistics::averager_base< Derived >::add ( double  x,
long  n = 1 
)
inline

add a data point

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

◆ add1() [1/2]

template<class Derived >
void theplu::yat::statistics::averager_base< Derived >::add1 ( double  x,
long int  n 
)
protected

add n data points with value x

◆ add1() [2/2]

template<class Derived >
void theplu::yat::statistics::averager_base< Derived >::add1 ( double  delta)
protected

add one data point with value delta + mean()

◆ mean()

template<class Derived>
double theplu::yat::statistics::averager_base< Derived >::mean ( void  ) const
inline

mean

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

◆ n()

template<class Derived>
long theplu::yat::statistics::averager_base< Derived >::n ( void  ) const
inline

number of data points

Returns
Number of data points

◆ rescale()

template<class Derived>
void theplu::yat::statistics::averager_base< Derived >::rescale ( double  a)
inline

Rescales the object.

$ \forall x_i \rightarrow a*x_i $,

◆ rescale1()

template<class Derived >
double theplu::yat::statistics::averager_base< Derived >::rescale1 ( double  x)
protected

rescale as $ mean \rightarrow x mean $

◆ reset()

template<class Derived>
void theplu::yat::statistics::averager_base< Derived >::reset ( void  )
inline

Reset object.

Restore Averager as if data were never added

◆ sum_x()

template<class Derived>
double theplu::yat::statistics::averager_base< Derived >::sum_x ( void  ) const
inline
Returns
The sum of data values

Member Data Documentation

◆ n_

template<class Derived>
long int theplu::yat::statistics::averager_base< Derived >::n_
protected

number of data points


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

Generated on Sat Feb 18 2023 03:31:45 for yat by  doxygen 1.8.14