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

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

#include <STK_Stat_Online.h>

Public Member Functions

 Online ()
 default constructor
 
 Online (Online const &stat)
 copy constructor
 
Real constmean () const
 
Real variance () const
 
void release ()
 release the computed parameters
 
void update (Real const &value)
 update the parameters using the current estimated parameters
 
Onlineoperator= (Online const &other)
 overwrite the statistics with other.
 

Public Attributes

Real mean_
 on line mean of the variable
 
Real variance_
 on line variance times n of the variable
 
int iter_
 number of stored values
 

Detailed Description

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

Definition at line 121 of file STK_Stat_Online.h.

Constructor & Destructor Documentation

◆ Online() [1/2]

STK::Stat::Online< Real, Real >::Online ( )
inline

default constructor

Definition at line 124 of file STK_Stat_Online.h.

124: mean_(0.), variance_(0.), iter_(0) {}
Real mean_
on line mean of the variable
int iter_
number of stored values
Real variance_
on line variance times n of the variable

◆ Online() [2/2]

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

copy constructor

Definition at line 126 of file STK_Stat_Online.h.

126 : mean_(stat.mean_), variance_(stat.variance_), iter_(stat.iter_)
127 {}

Member Function Documentation

◆ mean()

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

Definition at line 129 of file STK_Stat_Online.h.

129{ return mean_;}

◆ operator=()

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

overwrite the statistics with other.

Parameters
otherthe online statistics to copy

Definition at line 149 of file STK_Stat_Online.h.

150 {
151 mean_ = other.mean_;
152 variance_ = other.variance_;
153 iter_ = other.iter_;
154 return *this;
155 }

◆ release()

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

release the computed parameters

Definition at line 134 of file STK_Stat_Online.h.

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

◆ update()

void STK::Stat::Online< Real, Real >::update ( Real const value)
inline

update the parameters using the current estimated parameters

See also
https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Online_algorithm
Parameters
valuethe current value of the variable

Definition at line 139 of file STK_Stat_Online.h.

140 {
141 iter_++;
142 Real delta = value - mean_;
143 mean_ += delta/iter_;
144 variance_ = variance_ + delta*(value - mean_);
145 }
double Real
STK fundamental type of Real values.

◆ variance()

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

Definition at line 131 of file STK_Stat_Online.h.

Arithmetic properties of STK fundamental types.

Member Data Documentation

◆ iter_

number of stored values

Definition at line 161 of file STK_Stat_Online.h.

◆ mean_

on line mean of the variable

Definition at line 157 of file STK_Stat_Online.h.

◆ variance_

Real STK::Stat::Online< Real, Real >::variance_

on line variance times n of the variable

Definition at line 159 of file STK_Stat_Online.h.


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