CBOE Emulator  1.0
Public Member Functions | Static Public Attributes | List of all members
Maths::ExponentialMovingAverage< T > Struct Template Reference

A structure for calculating an exponential moving average. More...

#include <exponential_moving_average.hpp>

Public Member Functions

 ExponentialMovingAverage (T alpha_, T observation=0)
 Initialize an exponential moving average with given \(\alpha\) and \(o_0\). More...
 
void reset (T observation=0)
 Reset the average to initial state \({\mu}_0\) with observation \(o_0\). More...
 
void set_alpha (T alpha_)
 Set the \(\alpha\) parameter to a new value. More...
 
get_alpha () const
 Return the \(\alpha\) parameter. More...
 
void process (T observation)
 Calculate the next average \({\mu}_t\) based on observation \(o_t\). More...
 
get_average () const
 Return the current value of the exponential moving average \({\mu}_t\). More...
 

Static Public Attributes

static constexpr T ALPHA_MIN = 0
 the minimal value for alpha to take
 
static constexpr T ALPHA_MAX = 1
 the maximal value for alpha to take
 

Detailed Description

template<typename T = float>
struct Maths::ExponentialMovingAverage< T >

A structure for calculating an exponential moving average.

Template Parameters
Tthe type for the exponential moving average

The exponential moving average \({\mu}_t\) for event \(t\), corresponding observation \(o_t\), initial observation \(o_0\), and rate of change parameter \(\alpha\) is defined as:

\[ {\mu}_t \gets \alpha \cdot o_t + (1 - \alpha) \cdot {\mu}_{t - 1} | {\mu}_0 = o_0\]

where:

Constructor & Destructor Documentation

◆ ExponentialMovingAverage()

template<typename T = float>
Maths::ExponentialMovingAverage< T >::ExponentialMovingAverage ( alpha_,
observation = 0 
)
inlineexplicit

Initialize an exponential moving average with given \(\alpha\) and \(o_0\).

Parameters
alpha_the \(\alpha\) parameter, i.e., rate of change
observationthe initial observation \(o_0\) for the average

Member Function Documentation

◆ get_alpha()

template<typename T = float>
T Maths::ExponentialMovingAverage< T >::get_alpha ( ) const
inline

Return the \(\alpha\) parameter.

Returns
the \(\alpha\) parameter for calculating the average

◆ get_average()

template<typename T = float>
T Maths::ExponentialMovingAverage< T >::get_average ( ) const
inline

Return the current value of the exponential moving average \({\mu}_t\).

Returns
the current average \({\mu}_t\)

◆ process()

template<typename T = float>
void Maths::ExponentialMovingAverage< T >::process ( observation)
inline

Calculate the next average \({\mu}_t\) based on observation \(o_t\).

Parameters
observationthe observation \(o_t\) to integrate into the average

◆ reset()

template<typename T = float>
void Maths::ExponentialMovingAverage< T >::reset ( observation = 0)
inline

Reset the average to initial state \({\mu}_0\) with observation \(o_0\).

Parameters
observationthe initial observation \(o_0\) for the average

◆ set_alpha()

template<typename T = float>
void Maths::ExponentialMovingAverage< T >::set_alpha ( alpha_)
inline

Set the \(\alpha\) parameter to a new value.

Parameters
alpha_the \(\alpha\) parameter, i.e., rate of change

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