Gromacs  2025-dev-20240913-b871546
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions
gmx::ExponentialMovingAverage Class Reference

#include <gromacs/math/include/gromacs/math/exponentialmovingaverage.h>

Description

Evaluate the exponential moving average with bias correction.

The exponential moving average at the 0th data point $Y_0$ is $ S_0 = Y_0 $ and at the n-th data point $Y_n$ with n>0 it is $ S_n = \alpha Y_n + (1-\alpha) S_{n-1} $, where the smoothing factor $\alpha=1/t$ is determined via a time constant $t$.

To avoid large impact of the first data point in a "burn-in" phase, the weight of points are unbiased by substituting for $S_{n-1}$ above, $\hat{S}_{n-1} = S_{n-1} / (1-\alpha^{n})$.

Public Member Functions

 ExponentialMovingAverage (real timeConstant, const ExponentialMovingAverageState &state={})
 Construct by setting the time constant and state. Allows reinitiating with data from memory. More...
 
void updateWithDataPoint (real dataPoint)
 Update the moving average with a data point.
 
real biasCorrectedAverage () const
 The exponential weighted average with bias correction.
 
bool increasing () const
 Returns true if last added data point increased the average.
 
const
ExponentialMovingAverageState
state () const
 Return the current state of the exponential moving average.
 
real inverseTimeConstant () const
 The inverse time constant for the exponential moving average.
 

Constructor & Destructor Documentation

gmx::ExponentialMovingAverage::ExponentialMovingAverage ( real  timeConstant,
const ExponentialMovingAverageState state = {} 
)

Construct by setting the time constant and state. Allows reinitiating with data from memory.

Parameters
[in]timeConstanttime in number of data points
[in]stateof the exponential moving average
Exceptions
InconsistentInputErrorif timeConstant < 1

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