template <typename Value, typename Alpha, typename Beta>

class ExponentialAverage

Represents an exponential moving average. It is calculated as follows:

If the caller specifies only alpha, then a single-rate moving average is used. Letting Yn be the

value of the last observation, the moving average is calculated as:

Sn = Sn-1 + a * (Yn - Sn-1)

If the caller specifies both alpha and beta, then a dual-rate moving average is used:

D = Yn - Sn-1

{ Sn-1 + a * D if D

<

0

Sn = {

{ Sn-1 + b * D if D >= 0

In either case, the smoothing factors (a and b) are always required to be between 0 and 1.

This object also keeps track of the variance of the exponential moving average, which is

calculated as follows:

{ (1 - a) * (Vn-1 + a * D^2) if D

<

0

Vn = {

{ (1 - b) * (Vn-1 + b * D^2) if D >= 0

Because 0

<

= a

<

= 1 and 0

<

= b

<

= 1, this quantity must be non-negative.