yat  0.10.4pre
Public Member Functions | Protected Member Functions | Protected Attributes
theplu::yat::statistics::averager_base< Derived > Class Template Reference

Base class for averager classes. More...

#include </scratch/bob/jari/tmp/pristine/yat-0.10.x/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 >

List of all members.

Public Member Functions

 averager_base (void)
 Constructor.
virtual ~averager_base (void)=0
 Destructor.
void add (double x, long n=1)
 add a data point
double mean (void) const
 mean
long n (void) const
 number of data points
void rescale (double a)
 Rescales the object.
void reset (void)
 Reset object.
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, \c MyClass, needs to have the following features:
- \c <a href=http://www.sgi.com/tech/stl/DefaultConstructible.html>
     DefaultConstructible</a>
- \c <a href=http://www.boost.org/doc/libs/1_35_0/libs/utility/Assignable.html> Assignable</a>
- \c a function add_impl(double, long int)
- \c a function rescale_impl(double)

These two functions need to be public or if you dont want to
expose them to the world, make them private and declare \c
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 Mon Nov 11 2013 09:41:45 for yat by  doxygen 1.8.1