Fundamentals of Statistics contains material of various lectures and courses of H. Lohninger on statistics, data analysis and chemometrics......click here for more.


Moving Average

The moving average is a simple method to smooth measured data by replacing a data point with the average (or a weighted form of it) of its neighbors. In the most simple case, only three data points are taken and their average is calculated:

The averaging window is moved over the data, shifting it by one time step after each calculation ("moving average"). The moving average can be denoted in a more general form by

with 2k+1 defining the width of the moving window,
wi being the weights, and
x(t) being the data values at time t.

The weights wi are all 1.0 in the most simple case, resulting in the arithmetic mean of the values in the smoothing window. However, it is sometimes advisable to adjust the weights in a way that the value in the center of the window have more influence on the smoothed result than the values near the windows boundary (the smoothed output is some kind of a weighted mean).

Since the moving average - using its defintion above - always requires access to future measurements it can be calculated only offline. When the moving average has to be calculated online and in real time (which means we know only present and past values) the algorithm stays the same, however, the data window lags behind so that it contains only already known past values. The last value in the window is the most recent (present) value, all other values are in the past. The lag of the smoothing window results in a delay of the smoothed data stream by (k-1)/2 values.

A "classic" application of (shifted) moving averages can be found in the manifold smoothed averages shown in stock charts. These curves are used often by investors to make a statement about the future (i.e. whether the stock prices will move up or down) - whether this approach is especially clever may not be judged by the author.

Note that a moving average is closely related to Savitzky-Golay filtering and to FIR filters. The moving average corresponds to a low pass filter in signal processing, i.e. higher frequencies are attenuated while low frequencies pass through the filter.