latest version v1.9 - last update 10 Apr 2010 |
Functor which computes the statistics of a series of vectors. More...
#include <ltiSerialVectorStats.h>
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 () |
serialVectorStats & | copy (const serialVectorStats &other) |
serialVectorStats & | operator= (const serialVectorStats &other) |
virtual functor * | clone () const |
const parameters & | getParameters () 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 |
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.
lti::serialVectorStats< T >::serialVectorStats | ( | ) |
default constructor
lti::serialVectorStats< T >::serialVectorStats | ( | const serialVectorStats< T > & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::serialVectorStats< T >::~serialVectorStats | ( | ) | [virtual] |
destructor
void lti::serialVectorStats< T >::apply | ( | vector< T > & | mean, | |
matrix< T > & | covariance | |||
) | const |
void lti::serialVectorStats< T >::apply | ( | vector< T > & | mean, | |
vector< T > & | variance | |||
) | const |
returns mean and variance vectors of the data vectors considered so far.
mean | the result, where the mean will be put | |
variance | the result, where the variance will be put |
virtual functor* lti::serialVectorStats< T >::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this functor.
Reimplemented from lti::statisticsFunctor.
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.
void lti::serialVectorStats< T >::consider | ( | const vector< T > & | element | ) |
This function considers the given vector for computing the mean and variance.
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.
serialVectorStats& lti::serialVectorStats< T >::copy | ( | const serialVectorStats< T > & | other | ) |
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::statisticsFunctor.
void lti::serialVectorStats< T >::diagonal | ( | const matrix< sqrType > & | mat, | |
vector< T > & | diag | |||
) | const [protected] |
void lti::serialVectorStats< T >::getCovariance | ( | matrix< T > & | covar | ) | const |
The covariance of all vectors that have been considered so far.
void lti::serialVectorStats< T >::getMean | ( | vector< T > & | mean | ) | const |
The mean of all vectors that have been considered so far.
double lti::serialVectorStats< T >::getN | ( | ) | const |
return the number of elements considered so far
const parameters& lti::serialVectorStats< T >::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::statisticsFunctor.
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))
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.
const vector<T>& lti::serialVectorStats< T >::getSumOfVectors | ( | ) | const |
The sum of all vectors that have been considered so far.
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.
virtual const char* lti::serialVectorStats< T >::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("serialVectorStats")
Reimplemented from lti::statisticsFunctor.
void lti::serialVectorStats< T >::getVariance | ( | vector< T > & | var | ) | const |
The variance of all vectors that have been considered so far.
serialVectorStats& lti::serialVectorStats< T >::operator= | ( | const serialVectorStats< T > & | other | ) |
Alias for copy.
Reimplemented from lti::functor.
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>
void lti::serialVectorStats< T >::outerAcc | ( | const vector< T > & | a, | |
const vector< T > & | b, | |||
const int | n, | |||
matrix< sqrType > & | dest | |||
) | const [protected] |
void lti::serialVectorStats< T >::outerAcc | ( | const vector< T > & | a, | |
const vector< T > & | b, | |||
matrix< sqrType > & | dest | |||
) | const [protected] |
virtual bool lti::serialVectorStats< T >::read | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | [virtual] |
Reads this functor from the given handler.
Reimplemented from lti::functor.
void lti::serialVectorStats< T >::reset | ( | ) |
Reset the series, i.e.
discard all considered elements.
void lti::serialVectorStats< T >::setN | ( | double | newN | ) |
set the number of elements considered so far
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.