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

lti::varianceFunctor< T > Class Template Reference

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

#include <ltiVarianceFunctor.h>

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

List of all members.

Classes

class  parameters
 the parameters for the class varianceFunctor More...

Public Member Functions

 varianceFunctor ()
 varianceFunctor (const varianceFunctor &other)
virtual ~varianceFunctor ()
virtual const char * getTypeName () const
apply (const vector< T > &srcdest) const
T & apply (const vector< T > &src, T &dest) const
vector< T > & apply (const matrix< T > &src, vector< T > &dest) const
void varianceOfRows (const matrix< T > &src, vector< T > &dest) const
void varianceOfColumns (const matrix< T > &src, vector< T > &dest) const
covariance (const vector< T > &a, const vector< T > &b) const
void covarianceMatrixOfRows (const matrix< T > &src, matrix< T > &dest) const
void covarianceMatrixOfRows (const matrix< T > &src, matrix< T > &dest, vector< T > &mu) const
void slowCovarianceMatrixOfRows (const matrix< T > &src, matrix< T > &dest) const
void covarianceMatrixOfColumns (const matrix< T > &src, matrix< T > &dest) const
void covarianceMatrixOfColumns (const matrix< T > &src, matrix< T > &dest, vector< T > &mu) const
varianceFunctorcopy (const varianceFunctor &other)
virtual functorclone () const
const parametersgetParameters () const

Static Public Member Functions

static void covar2corrcoef (matrix< T > &cv)

Detailed Description

template<class T>
class lti::varianceFunctor< T >

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

Be careful with the terms used here. If you have following matrix

 |  5  6  10  2 |
 |  1 -2   4  4 |
 |  3  2   1 -3 |

The (empirical) varianceOfRows means the variance of all rows, i.e. a row vector containing the sum of the square of difference between each row vector and the mean vector of all rows, divided by the number of rows minus 1. This is (4 8 21 13).

The (empirical) varianceOfColumns means the variance of all columns, i.e. a column vector containing the sum of the square of difference between each column vector and the mean vector of all columns, divided by the number of columns minus 1. This is (8.667 4.667 2)^T.

The parameter parameters::rowWise indicates that the matrix will be seen as a set of row vectors (if true), or column vectors (false).


Constructor & Destructor Documentation

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

default constructor

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

copy constructor

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

destructor


Member Function Documentation

template<class T >
vector<T>& lti::varianceFunctor< T >::apply ( const matrix< T > &  src,
vector< T > &  dest 
) const

The result of this function depends on the value of parameters.rowWise.

If this parameter is true, the functor will compute a vector, whose elements contain each the variance of one column of the matrix (the computes the variance of the rows, where each row is a data point in n-dimensional space. if rowWise is false, the result vector contains the variance of the columns of the matrix (each column a data point).

Parameters:
src matrix<T> with the source data.
dest vector<T> where the result will be left.
Returns:
a reference to the dest.
template<class T >
T& lti::varianceFunctor< T >::apply ( const vector< T > &  src,
T &  dest 
) const

computes the variance of the given vector.

Parameters:
src vector<T> with the source data.
dest vector<T> where the result will be left.
Returns:
a reference to the dest.
template<class T >
T lti::varianceFunctor< T >::apply ( const vector< T > &  srcdest  )  const

returns the variance of the current vector.

Parameters:
srcdest vector<T> with the source data. The result will be left here too.
Returns:
a reference to the srcdest.
template<class T >
virtual functor* lti::varianceFunctor< T >::clone (  )  const [virtual]

returns a pointer to a clone of this functor.

Reimplemented from lti::statisticsFunctor.

template<class T >
varianceFunctor& lti::varianceFunctor< T >::copy ( const varianceFunctor< 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 >
static void lti::varianceFunctor< T >::covar2corrcoef ( matrix< T > &  cv  )  [static]

Converts a covariance matrix into a correlation coefficient matrix.

template<class T >
T lti::varianceFunctor< T >::covariance ( const vector< T > &  a,
const vector< T > &  b 
) const

The result is the covariance of these two vectors.

The vectors are regarded as series of outcomes of a twodimensional random variable. This function computes the covariance of both dimensions of the variable.

Parameters:
a vector<T> with dimension one of the random variable.
b vector<T> with dimension two of the random variable.
Returns:
covariance between a and b
template<class T >
void lti::varianceFunctor< T >::covarianceMatrixOfColumns ( const matrix< T > &  src,
matrix< T > &  dest,
vector< T > &  mu 
) const

This function will compute a matrix which contains the covariance matrix of the data points in the first matrix, if each column constitutes a data point in n-dimensional space.

Parameters:
src matrix<T> with the source data.
dest matrix<T> where the result will be left.
mu mean value of the data.
template<class T >
void lti::varianceFunctor< T >::covarianceMatrixOfColumns ( const matrix< T > &  src,
matrix< T > &  dest 
) const

This function will compute a matrix which contains the covariance matrix of the data points in the first matrix, if each column constitutes a data point in n-dimensional space.

Parameters:
src matrix<T> with the source data.
dest matrix<T> where the result will be left.
template<class T >
void lti::varianceFunctor< T >::covarianceMatrixOfRows ( const matrix< T > &  src,
matrix< T > &  dest,
vector< T > &  mu 
) const

This function will compute a matrix which contains the covariance matrix of the data points in the first matrix, if each row constitutes a data point in n-dimensional space.

Parameters:
src matrix<T> with the source data.
dest matrix<T> where the result will be left.
mu mean value of the data.
template<class T >
void lti::varianceFunctor< T >::covarianceMatrixOfRows ( const matrix< T > &  src,
matrix< T > &  dest 
) const

This function will compute a matrix which contains the covariance matrix of the data points in the first matrix, if each row constitutes a data point in n-dimensional space.

Parameters:
src matrix<T> with the source data.
dest matrix<T> where the result will be left.
template<class T >
const parameters& lti::varianceFunctor< T >::getParameters (  )  const

returns used parameters

Reimplemented from lti::statisticsFunctor.

template<class T >
virtual const char* lti::varianceFunctor< T >::getTypeName (  )  const [virtual]

returns the name of this type ("varianceFunctor")

Reimplemented from lti::statisticsFunctor.

template<class T >
void lti::varianceFunctor< T >::slowCovarianceMatrixOfRows ( const matrix< T > &  src,
matrix< T > &  dest 
) const

This function will compute a matrix which contains the covariance matrix of the data points in the first matrix, if each row constitutes a data point in n-dimensional space.

This is an older, slow version which has been left here, because there are a few rare cases when it is still somewhat faster than the new version.

Parameters:
src matrix<T> with the source data.
dest matrix<T> where the result will be left.
template<class T >
void lti::varianceFunctor< T >::varianceOfColumns ( const matrix< T > &  src,
vector< T > &  dest 
) const

The result vector contains the variances of the columns of the matrix (each column a data point).

Parameters:
src matrix<T> with the source data.
dest vector<T> where the result will be left.
template<class T >
void lti::varianceFunctor< T >::varianceOfRows ( const matrix< T > &  src,
vector< T > &  dest 
) const

This function will compute a vector, whose elements contain each the variance of one column of the matrix (the computes the variance of the rows, where each row is a data point in n-dimensional space).

Parameters:
src matrix<T> with the source data.
dest vector<T> where the result will be left.

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

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