|
1-phase PV router
|
Implements an Exponentially Weighted Moving Average (EWMA). More...
#include <ewma_avg.hpp>

Public Member Functions | |
| void | addValue (int32_t input) |
| Add a new value and update the EMA, DEMA, and TEMA. | |
| auto | getAverageD () const |
| Get the Double Exponentially Weighted Moving Average (DEMA). | |
| auto | getAverageS () const |
| Get the Exponentially Weighted Moving Average (EMA). | |
| auto | getAverageT () const |
| Get the Triple Exponentially Weighted Moving Average (TEMA). | |
Private Attributes | |
| int32_t | ema { 0 } |
| int32_t | ema_ema { 0 } |
| int32_t | ema_ema_ema { 0 } |
| int32_t | ema_ema_ema_raw { 0 } |
| int32_t | ema_ema_raw { 0 } |
| int32_t | ema_raw { 0 } |
Implements an Exponentially Weighted Moving Average (EWMA).
The EWMA_average class calculates the Exponentially Weighted Moving Average (EMA), Double EMA (DEMA), and Triple EMA (TEMA) for a given input series. It uses integer math for efficiency, making it suitable for systems with limited computational power.
| A | The smoothing factor, which determines the weight of recent values in the average. |
Definition at line 79 of file ewma_avg.hpp.
|
inline |
Add a new value and update the EMA, DEMA, and TEMA.
This method processes a new input value and updates the Exponentially Weighted Moving Average (EMA), Double EMA (DEMA), and Triple EMA (TEMA).
| input | The new input value to process. |
Definition at line 90 of file ewma_avg.hpp.
References ema, ema_ema, ema_ema_ema, ema_ema_ema_raw, ema_ema_raw, ema_raw, and round_up_to_power_of_2().

|
inline |
Get the Double Exponentially Weighted Moving Average (DEMA).
Definition at line 117 of file ewma_avg.hpp.
|
inline |
Get the Exponentially Weighted Moving Average (EMA).
Definition at line 107 of file ewma_avg.hpp.
References ema.
|
inline |
Get the Triple Exponentially Weighted Moving Average (TEMA).
Definition at line 127 of file ewma_avg.hpp.
References ema, ema_ema, and ema_ema_ema.
|
private |
EMA value.
Definition at line 138 of file ewma_avg.hpp.
Referenced by addValue(), getAverageD(), getAverageS(), and getAverageT().
|
private |
DEMA value.
Definition at line 136 of file ewma_avg.hpp.
Referenced by addValue(), getAverageD(), and getAverageT().
|
private |
TEMA value.
Definition at line 134 of file ewma_avg.hpp.
Referenced by addValue(), and getAverageT().
|
private |
Raw value for TEMA calculation.
Definition at line 133 of file ewma_avg.hpp.
Referenced by addValue().
|
private |
Raw value for DEMA calculation.
Definition at line 135 of file ewma_avg.hpp.
Referenced by addValue().
|
private |
Raw value for EMA calculation.
Definition at line 137 of file ewma_avg.hpp.
Referenced by addValue().