tzutrader
A composable C++ backtesting library for trading strategies (experimental)
Loading...
Searching...
No Matches
tzu::MVar Class Reference

#include <indicators.h>

Public Member Functions

 MVar (size_t window_size, size_t dof)
double get () const noexcept
double update (double value)

Detailed Description

Moving Variance (MVar)

Calculates the variance of the most recent N values. Returns NaN until enough values have been added to fill the window. Once the window is full, it calculates the variance using the formula:

Variance = (1 / (N - dof)) * sum((x_i - mean)^2)

where dof is the degrees of freedom, which is typically 1 for sample variance and 0 for population variance. The N template parameter specifies the size of the window.

The standard deviation can be obtained by taking the square root of the variance.

Constructor & Destructor Documentation

◆ MVar()

tzu::MVar::MVar ( size_t window_size,
size_t dof )
inline

Member Function Documentation

◆ get()

double tzu::MVar::get ( ) const
inlinenoexcept

◆ update()

double tzu::MVar::update ( double value)
inline

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