Momentum Scripting v1
Loading...
Searching...
No Matches
v1::ExponentialMovingAverageStatistic Class Reference

#include <Statistic.h>

Public Member Functions

 ExponentialMovingAverageStatistic (double smoothFactor, double initialObservation=0)
 
virtual ~ExponentialMovingAverageStatistic ()
 
double get () const
 
double getSmoothFactor () const
 
void set (double val)
 
void setSmoothFactor (double smoothFactor)
 
virtual double update (double observation)
 

Protected Attributes

double m_s
 
double m_smoothFactor
 

Detailed Description

Exponential moving average statistic.

At observation $Y_n$ the statistic $S_n$ is calculated as: $S_n = S_{n-1} + \alpha \left( Y_n - S_{n-1} \right)$, where $ 0 < \alpha < 1$ is the smoothing factor.

Constructor & Destructor Documentation

◆ ExponentialMovingAverageStatistic()

v1::ExponentialMovingAverageStatistic::ExponentialMovingAverageStatistic ( double  smoothFactor,
double  initialObservation = 0 
)
Parameters
smoothFactor- the smoothing factor used to propagate the average (must be between zero and one)
initialObservation- initial observation, default zero (optional)

◆ ~ExponentialMovingAverageStatistic()

virtual v1::ExponentialMovingAverageStatistic::~ExponentialMovingAverageStatistic ( )
virtual

Member Function Documentation

◆ get()

double v1::ExponentialMovingAverageStatistic::get ( ) const
virtual
Returns
the current value of this statistic

Implements v1::Statistic.

◆ getSmoothFactor()

double v1::ExponentialMovingAverageStatistic::getSmoothFactor ( ) const
Returns
the smoothing factor

◆ set()

void v1::ExponentialMovingAverageStatistic::set ( double  val)

Set the raw value of the statistic scalar.

This will be stored without any smoothing. Can be used to initialize the object to a specific value.

◆ setSmoothFactor()

void v1::ExponentialMovingAverageStatistic::setSmoothFactor ( double  smoothFactor)
Parameters
thesmoothing factor

◆ update()

virtual double v1::ExponentialMovingAverageStatistic::update ( double  observation)
virtual

Updates the statistic given the current observation and returns the current value of this statistic.

Parameters
observation- the current observation
Returns
the current value of this statistic

Implements v1::Statistic.

Member Data Documentation

◆ m_s

double v1::ExponentialMovingAverageStatistic::m_s
protected

◆ m_smoothFactor

double v1::ExponentialMovingAverageStatistic::m_smoothFactor
protected