RollingStats Class Reference

Space-ng SDK: sol3::math::RollingStats Class Reference
Space-ng SDK
sol3::math::RollingStats Class Reference

#include <sol3/math/rolling_stats.h>

Public Member Functions

 RollingStats (size_t window_size)
 
template<typename T >
void add (T value)
 
void clear ()
 Clear all samples and reset statistics. More...
 
size_t count () const
 Number of samples currently in the window. More...
 
size_t windowSize () const
 Maximum window size. More...
 
bool isFull () const
 Returns true if the window is full. More...
 
double mean () const
 Mean (first moment). More...
 
double variance () const
 
double stddev () const
 Standard deviation (square root of variance). More...
 

Detailed Description

Computes statistical moments over a rolling window of values.

Mean and variance are computed directly from the sample buffer, avoiding numerical drift from incremental update algorithms.

Example: RollingStats stats(100); // 100-sample window stats.add(42); stats.add(43); double mean = stats.mean(); double stddev = stats.stddev();

Constructor & Destructor Documentation

◆ RollingStats()

sol3::math::RollingStats::RollingStats ( size_t  window_size)
explicit

Construct a rolling statistics tracker with a fixed window size.

Parameters
window_sizeMaximum number of samples to track

Member Function Documentation

◆ add()

template<typename T >
void sol3::math::RollingStats::add ( value)
inline

Add a new value to the rolling window. If the window is full, the oldest value is removed.

◆ clear()

void sol3::math::RollingStats::clear ( )

Clear all samples and reset statistics.

◆ count()

size_t sol3::math::RollingStats::count ( ) const

Number of samples currently in the window.

◆ isFull()

bool sol3::math::RollingStats::isFull ( ) const

Returns true if the window is full.

◆ mean()

double sol3::math::RollingStats::mean ( ) const

Mean (first moment).

◆ stddev()

double sol3::math::RollingStats::stddev ( ) const

Standard deviation (square root of variance).

◆ variance()

double sol3::math::RollingStats::variance ( ) const

Variance (second central moment). Uses Bessel's correction (n-1) for sample variance.

◆ windowSize()

size_t sol3::math::RollingStats::windowSize ( ) const

Maximum window size.


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