35#ifndef STK_STAT_ONLINE_H
36#define STK_STAT_ONLINE_H
45template <
class Array,
class Type>
struct Online;
49template <
class Array>
52 typedef typename Array::Type
Type_;
58 inline Online(): mean_(), variance_(), iter_(0)
63 inline Online(
Range const& range): mean_(range), variance_(range), iter_(0)
68 inline Online(
Range const& rows,
Range const& cols): mean_(rows, cols), variance_(rows, cols), iter_(0)
76 Array
const&
mean()
const {
return mean_;}
82 { mean_.resize(range) = 0.; variance_.resize(range) = 0.; iter_ =0;}
85 { mean_.resize(rows, cols) = 0.; variance_.resize(rows, cols) = 0.; iter_ =0;}
87 inline void release() { mean_ = 0.; variance_ = 0.; iter_ = 0;}
95 Array
delta = x - mean_;
97 variance_ = variance_ +
delta.prod(x - mean_);
105 variance_ =
other.variance_;
124 Online(): mean_(0.), variance_(0.), iter_(0) {}
134 inline void release() { mean_ = 0.; variance_ = 0.; iter_ = 0;}
143 mean_ +=
delta/iter_;
144 variance_ = variance_ +
delta*(value - mean_);
152 variance_ =
other.variance_;
#define STK_STATIC_ASSERT(COND, MSG)
This file include all the header files of the project STKernel.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Index sub-vector region: Specialization when the size is unknown.
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.
Arithmetic properties of STK fundamental types.
Array variance_
on line variance
void resize(Range const &range)
initialize one dimensional arrays
Online()
default constructor
int iter_
number of stored values
Array const & mean() const
Array mean_
mean of the parameters
Online(Range const &rows, Range const &cols)
constructor for two dimensional arrays
void update(Array const &x)
update the parameters using the current estimated parameters
Online(Online const &stat)
copy constructor
Online & operator=(Online const &other)
overwrite the statistics with other.
void resize(Range const &rows, Range const &cols)
initialize two dimensional arrays
void release()
release the computed parameters
Online(Range const &range)
constructor for one dimensional arrays
Online()
default constructor
void update(Real const &value)
update the parameters using the current estimated parameters
Online & operator=(Online const &other)
overwrite the statistics with other.
Real mean_
on line mean of the variable
void release()
release the computed parameters
int iter_
number of stored values
Real variance_
on line variance times n of the variable
Online(Online const &stat)
copy constructor
Real const & mean() const
check if T and U are of the same type.