Class implementing moving average functionality. More...
#include <moving_average.h>
Public Member Functions | |
MovingAverage (uint length) | |
Create a moving average. | |
uint | Length () const |
Get the length of this moving average. | |
Tvalue | Monthly (const Tvalue &value) const |
Get the current average for 30 "length units" from the given value. | |
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 26 of file moving_average.h.
MovingAverage< Tvalue >::MovingAverage | ( | uint | length | ) | [inline] |
Create a moving average.
length | Length to be used. |
Definition at line 35 of file moving_average.h.
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 69 of file moving_average.h.
uint MovingAverage< Tvalue >::Length | ( | ) | const [inline] |
Get the length of this moving average.
Definition at line 44 of file moving_average.h.
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 59 of file moving_average.h.