LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::serialStatsFunctor< T, U > Class Template Reference

Functor which computes several kinds of means for vectors and matrices. More...

#include <ltiSerialStatsFunctor.h>

Inheritance diagram for lti::serialStatsFunctor< T, U >:
Inheritance graph
[legend]
Collaboration diagram for lti::serialStatsFunctor< T, U >:
Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 the parameters for the class meansFunctor More...

Public Member Functions

 serialStatsFunctor ()
 serialStatsFunctor (const serialStatsFunctor &other)
virtual ~serialStatsFunctor ()
virtual const char * getTypeName () const
void apply (U &mean, U &variance) const
void apply (vector< U > &mean, vector< U > &variance) const
void consider (const T &element)
void consider (const T &element, const int &n)
void consider (const vector< T > &element)
void consider (const vector< T > &element, const int &n)
void considerElements (const vector< T > &elements)
void considerElements (const matrix< T > &elements)
void considerElements (const matrix< T > &elements, const rectangle &rect)
void considerRows (const matrix< T > &elements)
getMean () const
getVariance () const
getSumOfElements () const
getSumOfSquares () const
int getN () const
int getNVectors () const
void getMean (vector< U > &m) const
void getVariance (vector< U > &v) const
void getSumOfVectors (vector< U > &s) const
void getSumOfVectorSquares (vector< U > &s) const
const vector< U > & getSumOfVectors () const
const vector< U > & getSumOfVectorSquares () const
void reset ()
serialStatsFunctorcopy (const serialStatsFunctor &other)
virtual functorclone () const
const parametersgetParameters () const

Detailed Description

template<class T, class U = T>
class lti::serialStatsFunctor< T, U >

Functor which computes several kinds of means for vectors and matrices.

It does NOT compute the extremes (min and max) of the considered values, which is the main difference with his brother functor lti::serialStatsFunctorExt

The first template parameter T describes the type of the vectors and matrices to be analysed. The second parameter U (usually the same type as T) specify the type of the statistics.

For example, if you want to compute the mean and variance of the elements {2,5,6,7,9} with double precision, you can use following code:

 lti::serialStatsFunctor<double> stats;
 double theAverage,theVariance;
 double data[] = {2,5,6,7,9};
 lti::vector vct(5,data);

 stats.considerElements(vct);
 stats.apply(theAverage,theVariance);
 cout << "Average: " << theAverage << " Variance: " << theVariance << endl;

It is also possible to compute the average/variance for each component withing lti::vectors.


Constructor & Destructor Documentation

template<class T, class U = T>
lti::serialStatsFunctor< T, U >::serialStatsFunctor (  ) 

default constructor

template<class T, class U = T>
lti::serialStatsFunctor< T, U >::serialStatsFunctor ( const serialStatsFunctor< T, U > &  other  ) 

copy constructor

Parameters:
other the object to be copied
template<class T, class U = T>
virtual lti::serialStatsFunctor< T, U >::~serialStatsFunctor (  )  [virtual]

destructor


Member Function Documentation

template<class T, class U = T>
void lti::serialStatsFunctor< T, U >::apply ( vector< U > &  mean,
vector< U > &  variance 
) const

returns mean and variance vectors of the data vectors considered so far.

Parameters:
mean the result, where the mean will be put
variance the result, where the variable will be put
template<class T, class U = T>
void lti::serialStatsFunctor< T, U >::apply ( U &  mean,
U &  variance 
) const

returns mean and variance of the data elements considered so far.

Parameters:
mean the result, where the mean will be put
variance the result, where the variable will be put
template<class T, class U = T>
virtual functor* lti::serialStatsFunctor< T, U >::clone (  )  const [virtual]

returns a pointer to a clone of this functor.

Reimplemented from lti::statisticsFunctor.

template<class T, class U = T>
void lti::serialStatsFunctor< T, U >::consider ( const vector< T > &  element,
const int &  n 
)

This function considers the given vector for computing the mean and variance, as if it were presented n times.

template<class T, class U = T>
void lti::serialStatsFunctor< T, U >::consider ( const vector< T > &  element  ) 

This function considers the given vector for computing the mean and variance.

template<class T, class U = T>
void lti::serialStatsFunctor< T, U >::consider ( const T &  element,
const int &  n 
)

This function considers the given element for computing the mean and variance as if it were presented n times.

template<class T, class U = T>
void lti::serialStatsFunctor< T, U >::consider ( const T &  element  ) 

This function considers the given element for computing the mean and variance.

template<class T, class U = T>
void lti::serialStatsFunctor< T, U >::considerElements ( const matrix< T > &  elements,
const rectangle rect 
)

Consider also all elements of the given matrix which lie within the given rectangle.

template<class T, class U = T>
void lti::serialStatsFunctor< T, U >::considerElements ( const matrix< T > &  elements  ) 

Consider also all elements of the given matrix.

template<class T, class U = T>
void lti::serialStatsFunctor< T, U >::considerElements ( const vector< T > &  elements  ) 

Consider also all elements of the given vector.

template<class T, class U = T>
void lti::serialStatsFunctor< T, U >::considerRows ( const matrix< T > &  elements  ) 

Consider all rows of the given matrix as vectors.

template<class T, class U = T>
serialStatsFunctor& lti::serialStatsFunctor< T, U >::copy ( const serialStatsFunctor< T, U > &  other  ) 

copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::statisticsFunctor.

template<class T, class U = T>
void lti::serialStatsFunctor< T, U >::getMean ( vector< U > &  m  )  const

The mean of all vectors that have been considered so far.

template<class T, class U = T>
U lti::serialStatsFunctor< T, U >::getMean (  )  const

The mean of all elements that have been considered so far.

template<class T, class U = T>
int lti::serialStatsFunctor< T, U >::getN (  )  const

return the number of elements considered so far

template<class T, class U = T>
int lti::serialStatsFunctor< T, U >::getNVectors (  )  const

return the number of vectors considered so far

template<class T, class U = T>
const parameters& lti::serialStatsFunctor< T, U >::getParameters (  )  const

returns used parameters

Reimplemented from lti::statisticsFunctor.

template<class T, class U = T>
U lti::serialStatsFunctor< T, U >::getSumOfElements (  )  const

The sum of all elements that have been considered so far.

template<class T, class U = T>
U lti::serialStatsFunctor< T, U >::getSumOfSquares (  )  const

The sum of the squares of of all elements that have been considered so far.

template<class T, class U = T>
const vector<U>& lti::serialStatsFunctor< T, U >::getSumOfVectors (  )  const

The sum of all vectors that have been considered so far.

Returns:
a read-only reference to the internal data
template<class T, class U = T>
void lti::serialStatsFunctor< T, U >::getSumOfVectors ( vector< U > &  s  )  const

The sum of all vectors that have been considered so far.

The values will be copied into the given vector.

template<class T, class U = T>
const vector<U>& lti::serialStatsFunctor< T, U >::getSumOfVectorSquares (  )  const

The sum of the squares of all vectors that have been considered so far.

Returns:
a read-only reference to the internal data
template<class T, class U = T>
void lti::serialStatsFunctor< T, U >::getSumOfVectorSquares ( vector< U > &  s  )  const

The sum of the squares of all vectors that have been considered so far.

The values will be copied into the given vector.

template<class T, class U = T>
virtual const char* lti::serialStatsFunctor< T, U >::getTypeName (  )  const [virtual]

returns the name of this type ("serialStatsFunctor")

Reimplemented from lti::statisticsFunctor.

template<class T, class U = T>
void lti::serialStatsFunctor< T, U >::getVariance ( vector< U > &  v  )  const

The variance of all vectors that have been considered so far.

template<class T, class U = T>
U lti::serialStatsFunctor< T, U >::getVariance (  )  const

The variance of all elements that have been considered so far.

template<class T, class U = T>
void lti::serialStatsFunctor< T, U >::reset (  ) 

Reset the series, i.e.

discard all considered elements.


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

Generated on Sat Apr 10 15:28:42 2010 for LTI-Lib by Doxygen 1.6.1