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

lti::entropyFunctor< T > Class Template Reference

Functor which computes entropy for vectors and matrices. More...

#include <ltiEntropyFunctor.h>

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

List of all members.

Classes

class  parameters
 the parameters for the class entropyFunctor More...

Public Member Functions

 entropyFunctor ()
 entropyFunctor (const bool &normalize, const bool &rowWise=true)
 entropyFunctor (const entropyFunctor &other)
virtual ~entropyFunctor ()
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
T & apply (const matrix< T > &src, T &dest) const
void entropyOfRows (const matrix< T > &src, vector< T > &dest) const
void entropyOfColumns (const matrix< T > &src, vector< T > &dest) const
entropyFunctorcopy (const entropyFunctor &other)
virtual functorclone () const
const parametersgetParameters () const

Detailed Description

template<class T>
class lti::entropyFunctor< T >

Functor which computes entropy for vectors and matrices.

The template parameter T corresponds to the value type of the objects to be evaluated. For example, to calculate the entropy of a vector<double> you will need an entropyFunctor<double>.

This functor assumes that the rows (or columns) of matrix contain probability distributions, i.e. the sum of the rows (column) elements must be 1.0. The entropy for the row will be defined as the sum of p(x)*ln(p(x)) for all x, where p(x) are the elements of the vector, row or column.


Constructor & Destructor Documentation

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

default constructor

template<class T >
lti::entropyFunctor< T >::entropyFunctor ( const bool &  normalize,
const bool &  rowWise = true 
)

constructor with parameter preinitialization

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

copy constructor

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

destructor


Member Function Documentation

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

computes the entropy of the given matrix.

Consider the matrix as a two-dimensional probability distribution.

The entropy is defined as the sum for all vector elements of p(x,y)*ln(p(x,y)), with p(x,y) = src.at(x,y).

Parameters:
src matrix<T> with the source data.
dest matrix<T> where the result will be left.
Returns:
a reference to the dest.
template<class T >
vector<T>& lti::entropyFunctor< 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 entropy of one column of the matrix (this computes the entropy of the rows, where each row is a data point in n-dimensional space. if rowWise is false, the result vector contains the entropy of the columns of the matrix (each column a data point).

The entropy of a row or column is defined as the sum for all its elements of p(x)*log2(p(x)), with p(x) = elements of the row or column.

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

computes the entropy of the given vector.

The entropy is defined as the sum for all vector elements of p(x)*ln(p(x)), with p(x) = srcdest.at(x). Warning: Elements that are less than zero are ignored.

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::entropyFunctor< T >::apply ( const vector< T > &  srcdest  )  const

returns the entropy of the current vector.

The entropy is defined as the sum for all vector elements of p(x)*ln(p(x)), with p(x) = srcdest.at(x). Warning: Elements that are less than zero are ignored.

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::entropyFunctor< T >::clone (  )  const [virtual]

returns a pointer to a clone of this functor.

Reimplemented from lti::statisticsFunctor.

template<class T >
entropyFunctor& lti::entropyFunctor< T >::copy ( const entropyFunctor< 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::entropyFunctor< T >::entropyOfColumns ( const matrix< T > &  src,
vector< T > &  dest 
) const

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

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

This function will compute a vector, whose elements contain each the entropy of one column of the matrix (this computes the entropy of the rows, where each row is 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::entropyFunctor< T >::getParameters (  )  const

returns used parameters

Reimplemented from lti::statisticsFunctor.

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

returns the name of this type ("entropyFunctor")

Reimplemented from lti::statisticsFunctor.


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

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