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

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

#include <exponential_moving_variance.hpp>

Public Member Functions

 ExponentialMovingVariance (T alpha_, T observation=0)
 Initialize an exponential moving variance with given \(\alpha\) and \(o_0\). More...
 
void reset (T observation=0)
 Reset the average to initial state \({\mu}_0\) with observation \(o_0\). The initial variance \({\sigma^2}_0\) is 0. More...
 
void set_alpha (T alpha_)
 Set the \(\alpha\) parameter to a new value. More...
 
get_alpha () const
 Return the \(\alpha\) parameter. More...
 
process (T observation)
 Calculate the next average \({\mu}_t\) and variance \({\sigma^2}_t\) based on observation \(o_t\). More...
 
get_average () const
 Return the current value of the exponential moving average \({\mu}_t\). More...
 
get_variance () const
 Return the current value of the exponential moving variance \({\sigma^2}_t\). More...
 
get_stddev () const
 Return the current value of the exponential moving standard deviation \({\sigma}_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::ExponentialMovingVariance< T >

A structure for calculating an exponential moving variance.

Template Parameters
Tthe type for the exponential moving average/variance

The change in value between the current average \({\mu}_{t-1}\) and next observation \(o_t\) for event \(t\) is defined as \(\delta_t\):

\[ \delta_t \gets o_t - {\mu}_{t-1} \]

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

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

The exponential moving variance \({\sigma}^2_t\) for event \(t\), corresponding change \(\delta_t\), and rate of change parameter \(\alpha\) is defined as:

\[ {\sigma^2}_t \gets (1 - \alpha) \cdot ({\sigma^2}_{t-1} + \alpha \cdot \delta^2_t) | {\sigma^2_0} = 0 \]

where:

Constructor & Destructor Documentation

◆ ExponentialMovingVariance()

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

Initialize an exponential moving variance 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::ExponentialMovingVariance< T >::get_alpha ( ) const
inline

Return the \(\alpha\) parameter.

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

◆ get_average()

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

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

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

◆ get_stddev()

template<typename T = float>
T Maths::ExponentialMovingVariance< T >::get_stddev ( ) const
inline

Return the current value of the exponential moving standard deviation \({\sigma}_t\).

Returns
the current standard deviation \({\sigma}_t\)

◆ get_variance()

template<typename T = float>
T Maths::ExponentialMovingVariance< T >::get_variance ( ) const
inline

Return the current value of the exponential moving variance \({\sigma^2}_t\).

Returns
the current variance \({\sigma^2}_t\)

◆ process()

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

Calculate the next average \({\mu}_t\) and variance \({\sigma^2}_t\) based on observation \(o_t\).

Parameters
observationthe observation \(o_t\) to integrate into the average and variance
Returns
the change in value between the observation and current average

◆ reset()

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

Reset the average to initial state \({\mu}_0\) with observation \(o_0\). The initial variance \({\sigma^2}_0\) is 0.

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

◆ set_alpha()

template<typename T = float>
void Maths::ExponentialMovingVariance< 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: