Public Member Functions | Protected Attributes

# MovingAverage< Tvalue > Class Template Reference

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

## Detailed Description

### template<class Tvalue>
class MovingAverage< Tvalue >

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.

Template Parameters:

  | 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.

## Constructor & Destructor Documentation

template<class Tvalue>

MovingAverage< Tvalue >::MovingAverage | ( | uint | length | ) | `[inline]`

Create a moving average.

Parameters:

  | length | Length to be used.

Definition at line 35 of file moving_average.h.

## Member Function Documentation

template<class Tvalue>

Tvalue& MovingAverage< Tvalue >::Decrease | ( | Tvalue & | value | ) | const`[inline]`

Decrease the given value using this moving average.

Parameters:

  | value | Moving average value to be decreased.

Returns:
  Decreased value.

Definition at line 69 of file moving_average.h.

template<class Tvalue>

uint MovingAverage< Tvalue >::Length | ( |  | ) | const`[inline]`

Get the length of this moving average.

Returns:
  Length.

Definition at line 44 of file moving_average.h.

template<class Tvalue>

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.

Parameters:

  | value | Raw moving average.

Returns:
  30 "length unit" average.

Definition at line 59 of file moving_average.h.

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

- src/moving_average.h