yat  0.13.2pre
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

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.

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

add n data points with value x

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

add one data point with value delta + 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 $
template<class Derived>
long theplu::yat::statistics::averager_base< Derived >::n ( void  ) const
inline

number of data points

Returns
Number of data points
template<class Derived>
void theplu::yat::statistics::averager_base< Derived >::rescale ( double  a)
inline

Rescales the object.

$ \forall x_i \rightarrow a*x_i $,

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

rescale as $ mean \rightarrow x mean $

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

Reset object.

Restore Averager as if data were never added

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

Member Data Documentation

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 Wed Jan 4 2017 02:23:08 for yat by  doxygen 1.8.5