Class implementing moving average functionality. More...
#include <moving_average.h>
Public Member Functions | |
FORCEINLINE | MovingAverage (uint length) |
Create a moving average. | |
FORCEINLINE uint | Length () const |
Get the length of this moving average. | |
FORCEINLINE Tvalue | Monthly (const Tvalue &value) const |
Get the current average for 30 "length units" from the given value. | |
FORCEINLINE Tvalue & | Decrease (Tvalue &value) const |
Decrease the given value using this moving average. | |
Protected Attributes | |
uint | length |
Class implementing moving average functionality.
An instance of this class can be used to get a meaningful (Monthly()) value from a moving average and it can be used to do the decrease operation.
Tvalue | Type supporting operator*(uint), operator/(uint), operator*=(uint) and operator/=(uint) with the usual semantics. |
Definition at line 27 of file moving_average.h.
FORCEINLINE MovingAverage< Tvalue >::MovingAverage | ( | uint | length | ) | [inline] |
Create a moving average.
length | Length to be used. |
Definition at line 36 of file moving_average.h.
FORCEINLINE Tvalue& MovingAverage< Tvalue >::Decrease | ( | Tvalue & | value | ) | const [inline] |
Decrease the given value using this moving average.
value | Moving average value to be decreased. |
Definition at line 70 of file moving_average.h.
FORCEINLINE uint MovingAverage< Tvalue >::Length | ( | ) | const [inline] |
Get the length of this moving average.
Definition at line 45 of file moving_average.h.
FORCEINLINE Tvalue MovingAverage< Tvalue >::Monthly | ( | const Tvalue & | value | ) | const [inline] |
Get the current average for 30 "length units" from the given value.
Mind that no one forces you to decrease the average daily. If you don't this is not a real "monthly" value. In any case it's not really "monthly" as we don't account for months with different numbers of days than 30. It doesn't matter, though. The point is to get an average over a defined past timeframe.
value | Raw moving average. |
Definition at line 60 of file moving_average.h.