DGtal
0.9.2
|
#include <DGtal/math/Statistic.h>
Public Types | |
typedef TQuantity | Quantity |
typedef std::vector< Quantity > | Container |
typedef Container::const_iterator | ConstIterator |
Public Member Functions | |
BOOST_CONCEPT_ASSERT ((concepts::CCommutativeRing< Quantity >)) | |
~Statistic () | |
Statistic (bool storeSample=false) | |
Statistic (const Statistic &other) | |
Statistic & | operator= (const Statistic &other) |
Statistic & | operator+= (const Statistic &other) |
Statistic | operator+ (const Statistic &other) const |
ConstIterator | begin () const |
ConstIterator | end () const |
unsigned int | samples () const |
double | mean () const |
double | variance () const |
double | unbiasedVariance () const |
Quantity | max () const |
Quantity | min () const |
Quantity | median () |
void | addValue (Quantity v) |
template<class Iter > | |
void | addValues (Iter b, Iter e) |
void | clear () |
void | terminate () |
void | selfDisplay (std::ostream &that_stream) const |
bool | OK () const |
Private Attributes | |
unsigned int | mySamples |
Quantity | myExp |
Quantity | myExp2 |
Quantity | myMax |
Quantity | myMin |
Quantity | myMedian |
Container | myValues |
bool | myStoreSamples |
bool | myIsTerminated |
Aim: This class processes a set of sample values for one variable and can then compute different statistics, like sample mean, sample variance, sample unbiased variance, etc. It is minimalistic for space efficiency. For multiple variables, sample storage and others, see Statistics class.
Description of class 'Statistic'
TQuantity | any model of CCommutativeRing. |
Definition at line 69 of file Statistic.h.
typedef Container::const_iterator DGtal::Statistic< TQuantity >::ConstIterator |
Definition at line 77 of file Statistic.h.
typedef std::vector< Quantity > DGtal::Statistic< TQuantity >::Container |
Definition at line 76 of file Statistic.h.
typedef TQuantity DGtal::Statistic< TQuantity >::Quantity |
Definition at line 74 of file Statistic.h.
DGtal::Statistic< TQuantity >::~Statistic | ( | ) |
Destructor.
DGtal::Statistic< TQuantity >::Statistic | ( | bool | storeSample = false | ) |
Constructor.
DGtal::Statistic< TQuantity >::Statistic | ( | const Statistic< TQuantity > & | other | ) |
Copy constructor.
other | the object to clone. |
void DGtal::Statistic< TQuantity >::addValue | ( | Quantity | v | ) |
Adds a new sample value [v].
v | the new sample value. |
Referenced by DGtal::CompareLocalEstimators< TFirstEsimator, TSecondEstimator >::compare(), and DGtal::CompareLocalEstimators< TFirstEsimator, TSecondEstimator >::compareVectors().
void DGtal::Statistic< TQuantity >::addValues | ( | Iter | b, |
Iter | e | ||
) |
Adds a sequence of sample values, scanning a container from iterators [b] to [e].
Exemple:
b | an iterator on the starting point. |
e | an iterator after the last point. |
ConstIterator DGtal::Statistic< TQuantity >::begin | ( | ) | const |
DGtal::Statistic< TQuantity >::BOOST_CONCEPT_ASSERT | ( | (concepts::CCommutativeRing< Quantity >) | ) |
void DGtal::Statistic< TQuantity >::clear | ( | ) |
Clears the object. As if it has just been created.
ConstIterator DGtal::Statistic< TQuantity >::end | ( | ) | const |
Quantity DGtal::Statistic< TQuantity >::max | ( | ) | const |
double DGtal::Statistic< TQuantity >::mean | ( | ) | const |
Quantity DGtal::Statistic< TQuantity >::median | ( | ) |
Return the median value of the Statistic values. It can be given in two possible cases:
Quantity DGtal::Statistic< TQuantity >::min | ( | ) | const |
bool DGtal::Statistic< TQuantity >::OK | ( | ) | const |
Checks the validity/consistency of the object.
Statistic DGtal::Statistic< TQuantity >::operator+ | ( | const Statistic< TQuantity > & | other | ) | const |
Adds two set of statistics (should be of the same variable).
other | the object to add. |
Statistic& DGtal::Statistic< TQuantity >::operator+= | ( | const Statistic< TQuantity > & | other | ) |
Adds to self another set of statistics (should be of the same variable).
other | the object to add. |
Statistic& DGtal::Statistic< TQuantity >::operator= | ( | const Statistic< TQuantity > & | other | ) |
Assignment.
other | the object to copy. |
unsigned int DGtal::Statistic< TQuantity >::samples | ( | ) | const |
void DGtal::Statistic< TQuantity >::selfDisplay | ( | std::ostream & | that_stream | ) | const |
Writes/Displays the object on an output stream.
that_stream | the output stream where the object is written. |
void DGtal::Statistic< TQuantity >::terminate | ( | ) |
Computes the median value of the statistics and switch to mode which does not save the statistics samples (myStoreSamples = false). Usefull only if the values are stored (specified in the the constructor) else it doest nothing.
Referenced by DGtal::CompareLocalEstimators< TFirstEsimator, TSecondEstimator >::compare(), and DGtal::CompareLocalEstimators< TFirstEsimator, TSecondEstimator >::compareVectors().
double DGtal::Statistic< TQuantity >::unbiasedVariance | ( | ) | const |
double DGtal::Statistic< TQuantity >::variance | ( | ) | const |
|
private |
stores the sum of sample values for computing sample mean.
Definition at line 251 of file Statistic.h.
|
private |
stores the sum of squared sample values for computing sample variance.
Definition at line 257 of file Statistic.h.
|
private |
Tells if terminate was called. Usefull to return median value even if the m_values are no more stored (possible after serialisation which doest store the values.).
Definition at line 295 of file Statistic.h.
|
private |
stores the maximal sample value.
Definition at line 262 of file Statistic.h.
|
private |
stores the median sample value.
Definition at line 273 of file Statistic.h.
|
private |
stores the minimal sample value.
Definition at line 267 of file Statistic.h.
|
private |
number of samples
Definition at line 246 of file Statistic.h.
|
private |
Tells if values must be stored or not.
Definition at line 286 of file Statistic.h.
|
private |
stores the sample to determine the median value
Definition at line 280 of file Statistic.h.