3-phase PV router
|
This file implements an Exponentially Weighted Moving Average template class. More...
Go to the source code of this file.
Classes | |
class | EWMA_average< A > |
Exponentially Weighted Moving Average. More... | |
Functions | |
constexpr uint8_t | round_up_to_power_of_2 (uint16_t v) |
Helper compile-time function to retrieve the previous power of 2 of the given number (120 => 64 => 6) | |
This file implements an Exponentially Weighted Moving Average template class.
The Exponentially Weighted Moving Average (EWMA) is a quantitative or statistical measure used to model or describe a time series. The EWMA is widely used in finance, the main applications being technical analysis and volatility modeling.
The moving average is designed as such that older observations are given lower weights. The weights fall exponentially as the data point gets older – hence the name exponentially weighted.
The only decision a user of the EWMA must make is the parameter alpha. The parameter decides how important the current observation is in the calculation of the EWMA. The higher the value of alpha, the more closely the EWMA tracks the original time series.
Computation of DEMA (Double EMA) with half-alpha has been added to get a better response of the average, especially when "peak inputs" are recorded.
Computation of TEMA (Triple EMA) with quarter-alpha has been added to get a even better response of the average, especially when "peak inputs" are recorded. This seems to be the "optimal" solution.
This class is implemented in way to use only integer math. This comes with some restrictions on the alpha parameter, but the benefit of full integer math wins on the side-drawback.
Definition in file ewma_avg.hpp.
|
constexpr |
Helper compile-time function to retrieve the previous power of 2 of the given number (120 => 64 => 6)
v | The input number |
Definition at line 47 of file ewma_avg.hpp.