STK++ 0.9.13
STK::Stat::Online< Array, Real > Struct Template Reference

Computation online of the statistics of a Real set of variable. More...

#include <STK_Stat_Online.h>

Public Types

enum  { value_ = hidden::isSame<Type_, Real>::value_ }
 
typedef Array::Type Type_
 

Public Member Functions

 Online ()
 default constructor
 
 Online (Range const &range)
 constructor for one dimensional arrays
 
 Online (Range const &rows, Range const &cols)
 constructor for two dimensional arrays
 
 Online (Online const &stat)
 copy constructor
 
Array constmean () const
 
Array variance () const
 
void resize (Range const &range)
 initialize one dimensional arrays
 
void resize (Range const &rows, Range const &cols)
 initialize two dimensional arrays
 
void release ()
 release the computed parameters
 
void update (Array const &x)
 update the parameters using the current estimated parameters
 
Onlineoperator= (Online const &other)
 overwrite the statistics with other.
 

Public Attributes

Array mean_
 mean of the parameters
 
Array variance_
 on line variance
 
int iter_
 number of stored values
 

Detailed Description

template<class Array>
struct STK::Stat::Online< Array, Real >

Computation online of the statistics of a Real set of variable.

Definition at line 50 of file STK_Stat_Online.h.

Member Typedef Documentation

◆ Type_

template<class Array >
typedef Array::Type STK::Stat::Online< Array, Real >::Type_

Definition at line 52 of file STK_Stat_Online.h.

Member Enumeration Documentation

◆ anonymous enum

template<class Array >
anonymous enum

Constructor & Destructor Documentation

◆ Online() [1/4]

template<class Array >
STK::Stat::Online< Array, Real >::Online ( )
inline

default constructor

Definition at line 58 of file STK_Stat_Online.h.

58 : mean_(), variance_(), iter_(0)
59 { STK_STATIC_ASSERT(value_, YOU_CANNOT_USED_THIS_TYPE_OF_DATA_WITH_THIS_OBJECT);
60 release();
61 }
#define STK_STATIC_ASSERT(COND, MSG)
int iter_
number of stored values
Array mean_
mean of the parameters
void release()
release the computed parameters

References STK_STATIC_ASSERT.

◆ Online() [2/4]

template<class Array >
STK::Stat::Online< Array, Real >::Online ( Range const range)
inline

constructor for one dimensional arrays

Definition at line 63 of file STK_Stat_Online.h.

63 : mean_(range), variance_(range), iter_(0)
64 { STK_STATIC_ASSERT(value_, YOU_CANNOT_USED_THIS_TYPE_OF_DATA_WITH_THIS_OBJECT);
65 release();
66 }

References STK_STATIC_ASSERT.

◆ Online() [3/4]

template<class Array >
STK::Stat::Online< Array, Real >::Online ( Range const rows,
Range const cols 
)
inline

constructor for two dimensional arrays

Definition at line 68 of file STK_Stat_Online.h.

68 : mean_(rows, cols), variance_(rows, cols), iter_(0)
69 { STK_STATIC_ASSERT(value_, YOU_CANNOT_USED_THIS_TYPE_OF_DATA_WITH_THIS_OBJECT);
70 release();
71 }

References STK_STATIC_ASSERT.

◆ Online() [4/4]

template<class Array >
STK::Stat::Online< Array, Real >::Online ( Online< Array, Real > const stat)
inline

copy constructor

Definition at line 73 of file STK_Stat_Online.h.

73 : mean_(stat.mean_), variance_(stat.variance_), iter_(stat.iter_)
74 {}

Member Function Documentation

◆ mean()

template<class Array >
Array const & STK::Stat::Online< Array, Real >::mean ( ) const
inline
Returns
the computed online mean

Definition at line 76 of file STK_Stat_Online.h.

76{ return mean_;}

◆ operator=()

template<class Array >
Online & STK::Stat::Online< Array, Real >::operator= ( Online< Array, Real > const other)
inline

overwrite the statistics with other.

Parameters
otherthe statistics to copy

Definition at line 102 of file STK_Stat_Online.h.

103 {
104 mean_ = other.mean_;
105 variance_ = other.variance_;
106 iter_ = other.iter_;
107 return *this;
108 }

◆ release()

template<class Array >
void STK::Stat::Online< Array, Real >::release ( )
inline

release the computed parameters

Definition at line 87 of file STK_Stat_Online.h.

87{ mean_ = 0.; variance_ = 0.; iter_ = 0;}

◆ resize() [1/2]

template<class Array >
void STK::Stat::Online< Array, Real >::resize ( Range const range)
inline

initialize one dimensional arrays

Definition at line 81 of file STK_Stat_Online.h.

82 { mean_.resize(range) = 0.; variance_.resize(range) = 0.; iter_ =0;}

◆ resize() [2/2]

template<class Array >
void STK::Stat::Online< Array, Real >::resize ( Range const rows,
Range const cols 
)
inline

initialize two dimensional arrays

Definition at line 84 of file STK_Stat_Online.h.

85 { mean_.resize(rows, cols) = 0.; variance_.resize(rows, cols) = 0.; iter_ =0;}

◆ update()

template<class Array >
void STK::Stat::Online< Array, Real >::update ( Array const x)
inline

update the parameters using the current estimated parameters

See also
https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Online_algorithm
Parameters
xthe current value

Definition at line 92 of file STK_Stat_Online.h.

93 {
94 iter_++;
95 Array delta = x - mean_;
96 mean_ += delta/iter_;
97 variance_ = variance_ + delta.prod(x - mean_);
98 }

◆ variance()

template<class Array >
Array STK::Stat::Online< Array, Real >::variance ( ) const
inline
Returns
the computed online variance

Definition at line 78 of file STK_Stat_Online.h.

Arithmetic properties of STK fundamental types.

Member Data Documentation

◆ iter_

template<class Array >
int STK::Stat::Online< Array, Real >::iter_

number of stored values

Definition at line 114 of file STK_Stat_Online.h.

◆ mean_

template<class Array >
Array STK::Stat::Online< Array, Real >::mean_

mean of the parameters

Definition at line 110 of file STK_Stat_Online.h.

◆ variance_

template<class Array >
Array STK::Stat::Online< Array, Real >::variance_

on line variance

Definition at line 112 of file STK_Stat_Online.h.


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