latest version v1.9 - last update 10 Apr 2010 |
Functor which computes entropy for vectors and matrices. More...
#include <ltiEntropyFunctor.h>
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 |
T | 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 |
entropyFunctor & | copy (const entropyFunctor &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
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.
lti::entropyFunctor< T >::entropyFunctor | ( | ) |
default constructor
lti::entropyFunctor< T >::entropyFunctor | ( | const bool & | normalize, | |
const bool & | rowWise = true | |||
) |
constructor with parameter preinitialization
lti::entropyFunctor< T >::entropyFunctor | ( | const entropyFunctor< T > & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::entropyFunctor< T >::~entropyFunctor | ( | ) | [virtual] |
destructor
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).
src | matrix<T> with the source data. | |
dest | matrix<T> where the result will be left. |
dest
. 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.
src | matrix<T> with the source data. | |
dest | matrix<T> where the result will be left. |
dest
. 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.
src | vector<T> with the source data. | |
dest | vector<T> where the result will be left. |
dest
. 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.
srcdest | vector<T> with the source data. The result will be left here too. |
srcdest
. virtual functor* lti::entropyFunctor< T >::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this functor.
Reimplemented from lti::statisticsFunctor.
entropyFunctor& lti::entropyFunctor< T >::copy | ( | const entropyFunctor< T > & | other | ) |
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::statisticsFunctor.
void lti::entropyFunctor< T >::entropyOfColumns | ( | const matrix< T > & | src, | |
vector< T > & | dest | |||
) | const |
void lti::entropyFunctor< T >::entropyOfRows | ( | const matrix< T > & | src, | |
vector< T > & | dest | |||
) | const |
const parameters& lti::entropyFunctor< T >::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::statisticsFunctor.
virtual const char* lti::entropyFunctor< T >::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("entropyFunctor")
Reimplemented from lti::statisticsFunctor.