DGtal
1.5.beta
|
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. More...
#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 |
unsigned int | size () const |
double | mean () const |
double | variance () const |
double | unbiasedVariance () const |
Quantity | max () const |
Quantity | min () const |
Quantity | median () |
Quantity | operator[] (unsigned int i) const |
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'
Backported from ImaGene. [78]
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 checkGenericPlane(), checkPlane(), DGtal::CompareLocalEstimators< TFirstEsimator, TSecondEstimator >::compare(), DGtal::CompareLocalEstimators< TFirstEsimator, TSecondEstimator >::compareVectors(), testHistogramGaussian(), testHistogramGaussian2(), testHistogramUniform(), testStatistics(), and testStatisticsSaving().
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. |
Referenced by DGtal::ShortcutsGeometry< TKSpace >::getStatistic().
ConstIterator DGtal::Statistic< TQuantity >::begin | ( | ) | const |
Referenced by testHistogramGaussian(), testHistogramGaussian2(), and testHistogramUniform().
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 |
Referenced by testHistogramGaussian(), testHistogramGaussian2(), and testHistogramUniform().
Quantity DGtal::Statistic< TQuantity >::max | ( | ) | const |
Referenced by testStatistics(), and testStatisticsSaving().
double DGtal::Statistic< TQuantity >::mean | ( | ) | const |
Referenced by main(), testStatistics(), and testStatisticsSaving().
Quantity DGtal::Statistic< TQuantity >::median | ( | ) |
Return the median value of the Statistic values. It can be given in two possible cases:
Referenced by testStatisticsSaving().
Quantity DGtal::Statistic< TQuantity >::min | ( | ) | const |
Referenced by testStatistics(), and testStatisticsSaving().
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. |
Quantity DGtal::Statistic< TQuantity >::operator[] | ( | unsigned int | i | ) | const |
[in] | i | a valid index |
unsigned int DGtal::Statistic< TQuantity >::samples | ( | ) | const |
Referenced by main().
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. |
unsigned int DGtal::Statistic< TQuantity >::size | ( | ) | const |
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(), DGtal::CompareLocalEstimators< TFirstEsimator, TSecondEstimator >::compareVectors(), DGtal::ShortcutsGeometry< TKSpace >::getStatistic(), main(), testHistogramGaussian(), testHistogramGaussian2(), testHistogramUniform(), testStatistics(), and testStatisticsSaving().
double DGtal::Statistic< TQuantity >::unbiasedVariance | ( | ) | const |
double DGtal::Statistic< TQuantity >::variance | ( | ) | const |
Referenced by main(), testStatistics(), and testStatisticsSaving().
|
private |
stores the sum of sample values for computing sample mean.
Definition at line 258 of file Statistic.h.
|
private |
stores the sum of squared sample values for computing sample variance.
Definition at line 264 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 302 of file Statistic.h.
|
private |
stores the maximal sample value.
Definition at line 269 of file Statistic.h.
|
private |
stores the median sample value.
Definition at line 280 of file Statistic.h.
|
private |
stores the minimal sample value.
Definition at line 274 of file Statistic.h.
|
private |
number of samples
Definition at line 253 of file Statistic.h.
|
private |
Tells if values must be stored or not.
Definition at line 293 of file Statistic.h.
|
private |
stores the sample to determine the median value
Definition at line 287 of file Statistic.h.