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

lti::serialVectorStats< T > Class Template Reference

Functor which computes the statistics of a series of vectors. More...

#include <ltiSerialVectorStats.h>

Inheritance diagram for lti::serialVectorStats< T >:
Inheritance graph
[legend]
Collaboration diagram for lti::serialVectorStats< T >:
Collaboration graph
[legend]

List of all members.

Classes

class  parameters
 the parameters for the class serialVectorStats More...

Public Member Functions

 serialVectorStats ()
 serialVectorStats (const serialVectorStats &other)
virtual ~serialVectorStats ()
virtual const char * getTypeName () const
void apply (vector< T > &mean, vector< T > &variance) const
void apply (vector< T > &mean, matrix< T > &covariance) const
void considerRows (const matrix< T > &element)
void consider (const vector< T > &element)
void consider (const vector< T > &element, const int &n)
double getN () const
void setN (double newN)
void getMean (vector< T > &mean) const
void getVariance (vector< T > &var) const
void getCovariance (matrix< T > &covar) const
void getSumOfVectors (vector< T > &s) const
void getSumOfVecOuterProd (matrix< sqrType > &s) const
const vector< T > & getSumOfVectors () const
const matrix< sqrType > & getSumOfVecOuterProd () const
void reset ()
serialVectorStatscopy (const serialVectorStats &other)
serialVectorStatsoperator= (const serialVectorStats &other)
virtual functorclone () const
const parametersgetParameters () const
virtual bool read (ioHandler &handler, const bool complete=true)
virtual bool write (ioHandler &handler, const bool complete=true) const

Protected Member Functions

void outer (const vector< T > &a, const vector< T > &b, matrix< sqrType > &dest) const
void outerAcc (const vector< T > &a, const vector< T > &b, matrix< sqrType > &dest) const
void outerAcc (const vector< T > &a, const vector< T > &b, const int n, matrix< sqrType > &dest) const
void diagonal (const matrix< sqrType > &mat, vector< T > &diag) const

Detailed Description

template<class T>
class lti::serialVectorStats< T >

Functor which computes the statistics of a series of vectors.

It delivers the mean vector and the covariance matrix, or alternatively the variance vector under the assumption, that the components of the vectors are independent from each other.

If the empirical computation type is selected, the variances resp. covariances will be normalized with (N-1). Otherwise with N.

An example (maximum-likelihood case, i.e. normalizing with N):

Assume we have three vectors {3,4},{1,3},{2,2}

The mean vector is {2,3}

The covariance matrix, which is always symetric, is:

 | 2/3  1/3  |
 | 1/3  2/3  |

The variance vector is {2/3,2/3}, i.e. the diagonal elements of the covariance matrix.


Constructor & Destructor Documentation

template<class T>
lti::serialVectorStats< T >::serialVectorStats (  ) 

default constructor

template<class T>
lti::serialVectorStats< T >::serialVectorStats ( const serialVectorStats< T > &  other  ) 

copy constructor

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

destructor


Member Function Documentation

template<class T>
void lti::serialVectorStats< T >::apply ( vector< T > &  mean,
matrix< T > &  covariance 
) const

returns mean vector and covariance matrix of the data vectors considered so far.

Parameters:
mean the result, where the mean will be put
covariance the matrix, where the covariances will be put
template<class T>
void lti::serialVectorStats< T >::apply ( vector< T > &  mean,
vector< T > &  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 variance will be put
template<class T>
virtual functor* lti::serialVectorStats< T >::clone (  )  const [virtual]

returns a pointer to a clone of this functor.

Reimplemented from lti::statisticsFunctor.

template<class T>
void lti::serialVectorStats< T >::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>
void lti::serialVectorStats< T >::consider ( const vector< T > &  element  ) 

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

template<class T>
void lti::serialVectorStats< T >::considerRows ( const matrix< T > &  element  ) 

This function considers the row vectors of the given matrix for computing the mean and variance.

template<class T>
serialVectorStats& lti::serialVectorStats< T >::copy ( const serialVectorStats< T > &  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>
void lti::serialVectorStats< T >::diagonal ( const matrix< sqrType > &  mat,
vector< T > &  diag 
) const [protected]

get diagonal vector of the given matrix, but casted into the lower type

template<class T>
void lti::serialVectorStats< T >::getCovariance ( matrix< T > &  covar  )  const

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

template<class T>
void lti::serialVectorStats< T >::getMean ( vector< T > &  mean  )  const

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

template<class T>
double lti::serialVectorStats< T >::getN (  )  const

return the number of elements considered so far

template<class T>
const parameters& lti::serialVectorStats< T >::getParameters (  )  const

returns used parameters

Reimplemented from lti::statisticsFunctor.

template<class T>
const matrix<sqrType>& lti::serialVectorStats< T >::getSumOfVecOuterProd (  )  const

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

(i.e. sum(vec*vecTransposed))

Returns:
a read-only reference to the internal data
template<class T>
void lti::serialVectorStats< T >::getSumOfVecOuterProd ( matrix< sqrType > &  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>
const vector<T>& lti::serialVectorStats< T >::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>
void lti::serialVectorStats< T >::getSumOfVectors ( vector< T > &  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>
virtual const char* lti::serialVectorStats< T >::getTypeName (  )  const [virtual]

returns the name of this type ("serialVectorStats")

Reimplemented from lti::statisticsFunctor.

template<class T>
void lti::serialVectorStats< T >::getVariance ( vector< T > &  var  )  const

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

template<class T>
serialVectorStats& lti::serialVectorStats< T >::operator= ( const serialVectorStats< T > &  other  ) 

Alias for copy.

Reimplemented from lti::functor.

template<class T>
void lti::serialVectorStats< T >::outer ( const vector< T > &  a,
const vector< T > &  b,
matrix< sqrType > &  dest 
) const [protected]

compute the outer product of two vector<T> and leave the result in a matrix<sqrType>

template<class T>
void lti::serialVectorStats< T >::outerAcc ( const vector< T > &  a,
const vector< T > &  b,
const int  n,
matrix< sqrType > &  dest 
) const [protected]

accumulate n times the outer product of a and b in the matrix dest The matrix dest MUST have the correct size before calling this method.

template<class T>
void lti::serialVectorStats< T >::outerAcc ( const vector< T > &  a,
const vector< T > &  b,
matrix< sqrType > &  dest 
) const [protected]

accumulate the outer product of a and b in the matrix dest The matrix dest MUST have the correct size before calling this method.

template<class T>
virtual bool lti::serialVectorStats< T >::read ( ioHandler handler,
const bool  complete = true 
) [virtual]

Reads this functor from the given handler.

Reimplemented from lti::functor.

template<class T>
void lti::serialVectorStats< T >::reset (  ) 

Reset the series, i.e.

discard all considered elements.

template<class T>
void lti::serialVectorStats< T >::setN ( double  newN  ) 

set the number of elements considered so far

template<class T>
virtual bool lti::serialVectorStats< T >::write ( ioHandler handler,
const bool  complete = true 
) const [virtual]

Writes this functor to the given handler.

Reimplemented from lti::functor.


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

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