Smoothing a time series plot

If a time series contains random variations, then fitting a linear trend is not very accurate. To ‘level out’ the data we use a technique called smoothing.

Mean smoothing

Three-moving mean

Each data value is replaced with the mean of that value and its two neighbours, one on each side. The first and last points do not have values on both sides so they are dismissed from the data set.


Using the data in Table 1, where y* represents the 3-point medians, a graph (Graph 1) is produced to demonstrate how the data values appear when they are smoothed out.

3 point moving means tableTable 1

3 point moving meansGraph 1

Five-moving mean

This method is the same as the three-point moving mean but finds the mean across five points. That is, the value itself and two neighbours from each side. The first and last two values are omitted as they do not have two values on each side of them.


When there are an even number of points, a process called centring must be used. This involves taking a 2-moving mean of the already smooth values so that they line up with the original time values. Therefore, as well as finding the smoothed values, a 2-point moving mean must also be done.


Four-point moving mean. 1

4 point moving meanTable 2

Median smoothing

The advantage of median smoothing over mean smoothing is it is primarily a graphical technique and that it is not influenced by a single outlier.

Three-moving median

Each data point is replaced with the median of that value and the values of its two neighbours, one on each side. Again, the first and last points do not have both neighbours and are therefore disregarded.

Five-moving median

In this case, the median of five points are used. The first and last two points do not have two values on each side and are therefore omitted from the smoothing.


y* represents a 3-moving median and y** represents a 5-moving median.

median moving 2
Table 3


Using these smoothing methods, the following graph (Graph 2) is produced. From observation alone, it is clear that the data has been smoothed out.

median movingGraph 2

See also:

  1. Four-point moving mean, Essential Further Mathematics 4th Edition Enhanced, pg 215