Signbit MPSCQ  0.5.0
Public Member Functions | List of all members
sbit::Stats Class Reference

#include <stats.h>

Public Member Functions

void reset () noexcept
 
void observe (double value) noexcept
 
size_t getCount () const noexcept
 
double getMean () const noexcept
 
double getVariance () const noexcept
 

Detailed Description

Maintain running statistics for a data stream

Implementation adapted from:

https://www.johndcook.com/blog/standard_deviation/

"There is a way to compute variance that is more accurate and is guaranteed to always give positive results. Furthermore, the method computes a running variance. That is, the method computes the variance as the x‘s arrive one at a time. The data do not need to be saved for a second pass.

This better way of computing variance goes back to a 1962 paper by B. P. Welford and is presented in Donald Knuth’s Art of Computer Programming, Vol 2, page 232, 3rd edition."

Member Function Documentation

◆ getCount()

size_t sbit::Stats::getCount ( ) const
inlinenoexcept
Returns
the number of observations

◆ getMean()

double sbit::Stats::getMean ( ) const
inlinenoexcept
Returns
the arithmetic mean statistic of the observations

◆ getVariance()

double sbit::Stats::getVariance ( ) const
inlinenoexcept
Returns
the variance statistic of the observations

◆ observe()

void sbit::Stats::observe ( double  value)
inlinenoexcept

Observe a new value and mix it in the statistics

Parameters
valueis the value that was observed

◆ reset()

void sbit::Stats::reset ( )
inlinenoexcept

Resets the statistics so the object can be reused


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