FastVarianceAccumulator class
FastVarianceAccumulator computes mean and standard deviation by accumulating the sum of sample
values and the sum of the square of sample values.
Samples are added one by one, using the Push method. Other members are used to retrieve estimates of
the population statistics based on the samples seen up to that point. Formula used to compute population
statistics are corrected, though the standard deviation is not an unbiased estimator. The accumulator
uses a simple algorithm that could result in catastrophic cancellation if the variance is very small with
respect to the mean; use dip::VarianceAccumulator to prevent it.
It is possible to accumulate samples in different objects (e.g. when processing with multiple threads),
and add the accumulators together using the + operator.
It is also possible to remove a sample from the accumulator, using the Pop method. It is assumed that the
particular value passed to this method had been added previously to the accumulator. If this is not the case,
resulting means and variances are no longer correct.
Functions
- auto Mean() const -> dip::dfloat
- Unbiased estimator of population mean
- auto Number() const -> dip::uint
- Number of samples
- void Pop(dip::dfloat x)
- Remove a sample from the accumulator
- void Push(dip::dfloat x)
- Add a sample to the accumulator
- void Reset()
- Reset the accumulator, leaving it as if newly allocated.
- auto StandardDeviation() const -> dip::dfloat
- Estimator of population standard deviation (it is not possible to derive an unbiased estimator)
- auto Variance() const -> dip::dfloat
- Unbiased estimator of population variance
Operators
- auto operator+=(dip::FastVarianceAccumulator const& b) -> dip::FastVarianceAccumulator&
- Combine two accumulators
Function documentation
void Reset( )
Reset the accumulator, leaving it as if newly allocated.
void Push( dip::dfloat x)
Add a sample to the accumulator
void Pop( dip::dfloat x)
Remove a sample from the accumulator
dip::dfloat Mean( ) const
Unbiased estimator of population mean
dip::dfloat Variance( ) const
Unbiased estimator of population variance
dip::dfloat StandardDeviation( ) const
Estimator of population standard deviation (it is not possible to derive an unbiased estimator)
dip::FastVarianceAccumulator& operator+=( dip::FastVarianceAccumulator const& b)
Combine two accumulators
dip::FastVarianceAccumulator
dip:: operator+(
dip::FastVarianceAccumulator lhs, dip::FastVarianceAccumulator const& rhs)
Combine two accumulators