Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
AbsEwma Class Reference

Exponentially weighted moving average. More...

#include <Ewma.hxx>

Public Member Functions

 AbsEwma (float alpha)
 
void set_alpha (float alpha)
 Sets the adjustment parameter.
 
void add_value (float value)
 Adds a step to the EWMA average.
 
void reset_state (float value)
 Clears the history and sets the state of the EWMA.
 
float avg ()
 

Public Attributes

float alpha_
 coefficient for EWMA
 
float avg_ {0.0}
 current state of EWMA
 

Detailed Description

Exponentially weighted moving average.

This class allows an O(1) representation of an average over a timeseries of data. This is the algorithm that Linux is using for the loadavg calculation. The algorithm is parametrized by a coefficient \alpha. The larger \alpha is, the longer "memory" the average has, meaning that the slower the average adapts to a changing situation.

Definition at line 136 of file Ewma.hxx.

Constructor & Destructor Documentation

◆ AbsEwma()

AbsEwma::AbsEwma ( float  alpha)
inline
Parameters
alphaewma coefficient. The lower the value is the faster the average converges to current speed. The higher this value is the more the averaging will smoothe the speed values read out.

Definition at line 142 of file Ewma.hxx.

Member Function Documentation

◆ add_value()

void AbsEwma::add_value ( float  value)
inline

Adds a step to the EWMA average.

Parameters
valueis the currently observed value to add to the average.

Definition at line 156 of file Ewma.hxx.

◆ avg()

float AbsEwma::avg ( )
inline
Returns
average.

Definition at line 176 of file Ewma.hxx.

◆ reset_state()

void AbsEwma::reset_state ( float  value)
inline

Clears the history and sets the state of the EWMA.

Parameters
valuethe desired new average.

Definition at line 170 of file Ewma.hxx.

◆ set_alpha()

void AbsEwma::set_alpha ( float  alpha)
inline

Sets the adjustment parameter.

Parameters
alphathe new value of the adjustment parameter.

Definition at line 149 of file Ewma.hxx.

Member Data Documentation

◆ alpha_

float AbsEwma::alpha_

coefficient for EWMA

Definition at line 181 of file Ewma.hxx.

◆ avg_

float AbsEwma::avg_ {0.0}

current state of EWMA

Definition at line 182 of file Ewma.hxx.


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