latest version v1.9 - last update 10 Apr 2010 |
Functor which computes several kinds of means for vectors and matrices. More...
#include <ltiSerialStatsFunctor.h>
Classes | |
class | parameters |
the parameters for the class meansFunctor More... | |
Public Member Functions | |
serialStatsFunctor () | |
serialStatsFunctor (const serialStatsFunctor &other) | |
virtual | ~serialStatsFunctor () |
virtual const char * | getTypeName () const |
void | apply (U &mean, U &variance) const |
void | apply (vector< U > &mean, vector< U > &variance) const |
void | consider (const T &element) |
void | consider (const T &element, const int &n) |
void | consider (const vector< T > &element) |
void | consider (const vector< T > &element, const int &n) |
void | considerElements (const vector< T > &elements) |
void | considerElements (const matrix< T > &elements) |
void | considerElements (const matrix< T > &elements, const rectangle &rect) |
void | considerRows (const matrix< T > &elements) |
U | getMean () const |
U | getVariance () const |
U | getSumOfElements () const |
U | getSumOfSquares () const |
int | getN () const |
int | getNVectors () const |
void | getMean (vector< U > &m) const |
void | getVariance (vector< U > &v) const |
void | getSumOfVectors (vector< U > &s) const |
void | getSumOfVectorSquares (vector< U > &s) const |
const vector< U > & | getSumOfVectors () const |
const vector< U > & | getSumOfVectorSquares () const |
void | reset () |
serialStatsFunctor & | copy (const serialStatsFunctor &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
Functor which computes several kinds of means for vectors and matrices.
It does NOT compute the extremes (min and max) of the considered values, which is the main difference with his brother functor lti::serialStatsFunctorExt
The first template parameter T describes the type of the vectors and matrices to be analysed. The second parameter U (usually the same type as T) specify the type of the statistics.
For example, if you want to compute the mean and variance of the elements {2,5,6,7,9} with double precision, you can use following code:
lti::serialStatsFunctor<double> stats; double theAverage,theVariance; double data[] = {2,5,6,7,9}; lti::vector vct(5,data); stats.considerElements(vct); stats.apply(theAverage,theVariance); cout << "Average: " << theAverage << " Variance: " << theVariance << endl;
It is also possible to compute the average/variance for each component withing lti::vectors.
lti::serialStatsFunctor< T, U >::serialStatsFunctor | ( | ) |
default constructor
lti::serialStatsFunctor< T, U >::serialStatsFunctor | ( | const serialStatsFunctor< T, U > & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::serialStatsFunctor< T, U >::~serialStatsFunctor | ( | ) | [virtual] |
destructor
void lti::serialStatsFunctor< T, U >::apply | ( | vector< U > & | mean, | |
vector< U > & | 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 variable will be put |
void lti::serialStatsFunctor< T, U >::apply | ( | U & | mean, | |
U & | variance | |||
) | const |
returns mean and variance of the data elements considered so far.
mean | the result, where the mean will be put | |
variance | the result, where the variable will be put |
virtual functor* lti::serialStatsFunctor< T, U >::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this functor.
Reimplemented from lti::statisticsFunctor.
void lti::serialStatsFunctor< T, U >::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::serialStatsFunctor< T, U >::consider | ( | const vector< T > & | element | ) |
This function considers the given vector for computing the mean and variance.
void lti::serialStatsFunctor< T, U >::consider | ( | const T & | element, | |
const int & | n | |||
) |
This function considers the given element for computing the mean and variance as if it were presented n times.
void lti::serialStatsFunctor< T, U >::consider | ( | const T & | element | ) |
This function considers the given element for computing the mean and variance.
void lti::serialStatsFunctor< T, U >::considerElements | ( | const matrix< T > & | elements, | |
const rectangle & | rect | |||
) |
Consider also all elements of the given matrix which lie within the given rectangle.
void lti::serialStatsFunctor< T, U >::considerElements | ( | const matrix< T > & | elements | ) |
Consider also all elements of the given matrix.
void lti::serialStatsFunctor< T, U >::considerElements | ( | const vector< T > & | elements | ) |
Consider also all elements of the given vector.
void lti::serialStatsFunctor< T, U >::considerRows | ( | const matrix< T > & | elements | ) |
Consider all rows of the given matrix as vectors.
serialStatsFunctor& lti::serialStatsFunctor< T, U >::copy | ( | const serialStatsFunctor< T, U > & | other | ) |
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::statisticsFunctor.
void lti::serialStatsFunctor< T, U >::getMean | ( | vector< U > & | m | ) | const |
The mean of all vectors that have been considered so far.
U lti::serialStatsFunctor< T, U >::getMean | ( | ) | const |
The mean of all elements that have been considered so far.
int lti::serialStatsFunctor< T, U >::getN | ( | ) | const |
return the number of elements considered so far
int lti::serialStatsFunctor< T, U >::getNVectors | ( | ) | const |
return the number of vectors considered so far
const parameters& lti::serialStatsFunctor< T, U >::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::statisticsFunctor.
U lti::serialStatsFunctor< T, U >::getSumOfElements | ( | ) | const |
The sum of all elements that have been considered so far.
U lti::serialStatsFunctor< T, U >::getSumOfSquares | ( | ) | const |
The sum of the squares of of all elements that have been considered so far.
const vector<U>& lti::serialStatsFunctor< T, U >::getSumOfVectors | ( | ) | const |
The sum of all vectors that have been considered so far.
void lti::serialStatsFunctor< T, U >::getSumOfVectors | ( | vector< U > & | s | ) | const |
The sum of all vectors that have been considered so far.
The values will be copied into the given vector.
const vector<U>& lti::serialStatsFunctor< T, U >::getSumOfVectorSquares | ( | ) | const |
The sum of the squares of all vectors that have been considered so far.
void lti::serialStatsFunctor< T, U >::getSumOfVectorSquares | ( | vector< U > & | 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.
virtual const char* lti::serialStatsFunctor< T, U >::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("serialStatsFunctor")
Reimplemented from lti::statisticsFunctor.
void lti::serialStatsFunctor< T, U >::getVariance | ( | vector< U > & | v | ) | const |
The variance of all vectors that have been considered so far.
U lti::serialStatsFunctor< T, U >::getVariance | ( | ) | const |
The variance of all elements that have been considered so far.
void lti::serialStatsFunctor< T, U >::reset | ( | ) |
Reset the series, i.e.
discard all considered elements.