Resources For Teachers For Tutors For Students & Parents AI New Books Pricing
Year 12 General (Unit 3 & 4) Time series analysis

Smoothing with moving averages

20 practice questions 0 video lessons Theory + worked examples

Learn how moving averages smooth a bumpy time series in Year 12 General Mathematics for Queensland (QCAA). Daily crowds at a Sunshine Coast beach or weekly sales at a Brisbane market jump around from one period to the next, and averaging neighbouring values cuts through that noise so the real direction is easier to see.

You will practise calculating 3-point and 5-point moving means and moving medians, placing each one on the middle period, choosing a median when an outlier is present, and building the same calculations in a spreadsheet. Next, seasonal indices remove a repeating calendar pattern from the data.

Create a free accountTrack your progress and save your work as you go.
Create free account

Theory

Moving averages smooth out the random ups and downs in a time series so the trend stands out. This Year 12 General Mathematics guide for Queensland students shows how to calculate 3-point and 5-point moving means and medians, centre them correctly and set them up in a spreadsheet.

Real time series data jump up and down from one period to the next, which can hide the overall pattern. Smoothing replaces each value with an average of the values around it, so the random ups and downs (irregular fluctuations) shrink and the trend is easier to see.

A \(k\)-point moving mean is the mean of \(k\) consecutive values; a \(k\)-point moving median is the middle value of \(k\) consecutive values once they are sorted. Here \(k\) is always an odd number, usually \(3\) or \(5\), so each window has a middle time period and the smoothed value is placed (centred) on that period.

The window then moves along one period at a time, giving a new smoothed value for each period. There are no smoothed values for the first and last \(\dfrac{k-1}{2}\) periods, because a full window does not fit there.

Key idea. A 3-point moving mean centred on period \(t\) is the mean of the values at \(t-1\), \(t\) and \(t+1\). More points give a smoother series, and a moving median is less affected by a one-off outlier than a moving mean.
Weekly pie sales with a 3-point moving meanTen weekly values that zig-zag up and down (solid), with a dashed 3-point moving mean from week 2 to week 9 that rises smoothly 50 55 60 65 70 75 80 85 1 2 3 4 5 6 7 8 9 10 Pies sold
The solid line is the raw weekly data; the dashed line is the 3-point moving mean. Smoothing removes the zig-zag and shows a steady increasing trend. The first and last weeks have no moving mean.
A 3-point moving median ignores a one-off spikeNine values with a single spike to 64 at time 5 (solid); the dashed 3-point moving median runs from 25 to 31 and does not follow the spike 20 30 40 50 60 70 1 2 3 4 5 6 7 8 9 Value
A one-off spike at time \(5\): the 3-point moving median (dashed) stays near \(30\), because the median ignores the extreme value. A moving mean would be pulled up by it.

A 3-point and a 5-point moving mean centred on time period \(t\), where \(y_t\) is the value at period \(t\):

\[\text{3-point mean at } t = \dfrac{y_{t-1} + y_t + y_{t+1}}{3}\]
3-point mean=yt−1+yt+yt+13
\[\text{5-point mean at } t = \dfrac{y_{t-2} + y_{t-1} + y_t + y_{t+1} + y_{t+2}}{5}\]
5-point mean=yt−2+⋯+yt+25

The moving median uses the same window but takes the middle value after sorting. With \(n\) values and a \(k\)-point window:

\[\text{number of smoothed values} = n - k + 1\]
number of smoothed values=n−k+1

In a spreadsheet (time in column A, data in column B starting in row 2, smoothed values in column C):

SmoothingFormula in the row for period \(t\) (row \(r\))
3-point moving mean=AVERAGE(B(r−1):B(r+1)), e.g. =AVERAGE(B2:B4) in C3
5-point moving mean=AVERAGE(B(r−2):B(r+2)), e.g. =AVERAGE(B2:B6) in C4
3-point moving median=MEDIAN(B(r−1):B(r+1)), e.g. =MEDIAN(B2:B4) in C3

Fill the formula down column C; leave the cells where a full window does not fit empty.

Calculating a moving mean or median

  1. Pick the window. For a 3-point value centred on period \(t\), use \(t-1\), \(t\) and \(t+1\); for 5 points use \(t-2\) to \(t+2\).
  2. Mean: add the values in the window and divide by the number of points. Median: sort the values in the window and take the middle one.
  3. Place the answer on the middle period of the window, and round (usually to \(1\) decimal place) only at the end.
  4. Slide the window on by one period and repeat until the window reaches the last value.

Interpreting the smoothed series

  1. Plot the smoothed values on the same axes as the data, at their middle periods.
  2. Describe the trend the smoothed line shows, now that the irregular fluctuations are reduced.
  3. If the data contain an outlier, prefer a moving median; for a smoother line, use more points (5 rather than 3).
Example 1 β€” A 3-point moving mean
A stall at the Gympie markets records the number of jars of honey it sells each week.
Week1234567
Jars sold34413845404944
(i) Calculate the 3-point moving mean centred on week \(2\), correct to one decimal place. (ii) How many 3-point moving means can be calculated, and for which weeks? (iii) Find them all and describe the trend.
Solution

The window centred on week \(2\) is weeks \(1\), \(2\) and \(3\).

\(\text{mean}_2\)\(=\)\(\dfrac{34 + 41 + 38}{3}\)
\(\text{mean}_2\)\(=\)\(\dfrac{113}{3}\)
\(\text{mean}_2\)\(\approx\)\(37.7\)
\(\text{number}\)\(=\)\(n - k + 1 = 7 - 3 + 1\)
\(\text{number}\)\(=\)\(5\)

(i) \(37.7\) jars. (ii) \(5\) moving means, for weeks \(2\) to \(6\) (weeks \(1\) and \(7\) have no full window).

Week23456
3-point mean\(37.7\)\(41.3\)\(41\)\(44.7\)\(44.3\)
Example 1: honey sales and the 3-point moving meanSeven weekly values (solid) and five 3-point moving means for weeks 2 to 6 (dashed), which rise more smoothly 32 36 40 44 48 52 1 2 3 4 5 6 7 Jars sold

(iii) The moving means rise overall from \(37.7\) to \(44.3\), with only tiny dips: an increasing trend.

Example 2 β€” A 5-point moving median and an outlier
The number of swimmers at a Townsville rock pool is counted each day. A storm kept people away on day \(5\).
Day123456789
Swimmers8692889531979310198
(i) Find the 5-point moving median centred on day \(3\). (ii) Find the 5-point moving median and the 5-point moving mean centred on day \(5\). (iii) Which is the better smoothed value for day \(5\)?
Solution

Use days \(1\) to \(5\) for day \(3\), and days \(3\) to \(7\) for day \(5\). Sort before taking a median.

\(\text{days 1-5 sorted}\)\(:\)\(31,\ 86,\ 88,\ 92,\ 95\)
\(\text{median}_3\)\(=\)\(88\)
\(\text{days 3-7 sorted}\)\(:\)\(31,\ 88,\ 93,\ 95,\ 97\)
\(\text{median}_5\)\(=\)\(93\)
\(\text{mean}_5\)\(=\)\(\dfrac{88 + 95 + 31 + 97 + 93}{5}\)
\(\text{mean}_5\)\(=\)\(\dfrac{404}{5}\)
\(\text{mean}_5\)\(=\)\(80.8\)

(i) \(88\). (ii) Median \(93\), mean \(80.8\).

(iii) The storm value \(31\) is an outlier. It drags the mean down to \(80.8\), well below the normal level of about \(90\), but the median ignores it, so the moving median (\(93\)) is better here.

Example 3 β€” Moving means in a spreadsheet
A Rockhampton business smooths its monthly online orders with a 5-point moving mean in a spreadsheet.
ABC
1MonthOrders5-point moving mean
2Jan212
3Feb198
4Mar225=AVERAGE(B2:B6)
5Apr240
6May231
7Jun256
8Jul249
9Aug270
(i) Explain the formula in cell C4 and find the value it displays. (ii) Which cells in column C are left empty? (iii) What formula goes in C7, and what does it display?
Solution

Row 4 is March (the 3rd month); a 5-point window reaches two rows up and two rows down.

\(\text{C4}\)\(:\)\(\text{mean of B2 to B6 (Jan to May), centred on Mar}\)
\(\text{C4}\)\(=\)\(\dfrac{212 + 198 + 225 + 240 + 231}{5}\)
\(\text{C4}\)\(=\)\(\dfrac{1106}{5}\)
\(\text{C4}\)\(=\)\(221.2\)
\(\text{C7}\)\(:\)\(\texttt{=AVERAGE(B5:B9)}\)
\(\text{C7}\)\(=\)\(\dfrac{1246}{5}\)
\(\text{C7}\)\(=\)\(249.2\)

(i) C4 averages the five months January to May and places the result on March: \(221.2\). (ii) C2, C3 (January, February) and C8, C9 (July, August) stay empty, because a 5-point window does not fit. (iii) =AVERAGE(B5:B9), displaying \(249.2\).

Example 4 β€” Find a missing value
A Toowoomba guesthouse records its weekly bookings, but the value for week \(2\) is missing. The 3-point moving mean centred on week \(2\) is \(61\).
Week123456
Bookings58\(x\)67637270
(i) Find \(x\). (ii) Calculate the remaining 3-point moving means, correct to one decimal place, and describe the trend.
Solution

The three values centred on week \(2\) must add to \(3 \times 61\).

\(\dfrac{58 + x + 67}{3}\)\(=\)\(61\)
\(58 + x + 67\)\(=\)\(183\)
\(x\)\(=\)\(183 - 125\)
\(x\)\(=\)\(58\)
\(\text{mean}_3\)\(=\)\(\dfrac{58 + 67 + 63}{3} \approx 62.7\)
\(\text{mean}_4\)\(=\)\(\dfrac{67 + 63 + 72}{3} \approx 67.3\)
\(\text{mean}_5\)\(=\)\(\dfrac{63 + 72 + 70}{3} \approx 68.3\)

(i) \(x = 58\) bookings. (ii) The moving means \(61,\ 62.7,\ 67.3,\ 68.3\) rise every week, so the bookings show an increasing trend.

Common pitfalls

Centre the value on the middle period. The 3-point mean of weeks \(4\), \(5\) and \(6\) belongs to week \(5\), not week \(4\) or week \(6\). Plot it there too.
Sort before you take a median. The median of \(47, 62, 39\) is \(47\) (the middle of \(39, 47, 62\)), not \(62\), the value that happens to be in the middle position.
Do not invent end values. With a 5-point window, the first two and last two periods have no moving mean, so a series of \(n\) values gives only \(n - 4\) smoothed values.

Frequently asked questions

Why do we smooth a time series?

Smoothing averages out the random, short-term ups and downs so that the long-term trend is easier to see and describe.

How do I calculate a 3-point moving mean?

Add the value for the period you want and the values just before and just after it, divide by 3, and place the answer on that middle period. Then move the window along one period and repeat.

When should I use a moving median instead of a moving mean?

Use a moving median when the data contain an outlier, such as a one-off spike or dip. The median is the middle value of the sorted window, so a single extreme value has little effect on it.

Why does the number of points have to be odd?

With an odd number of points, such as 3 or 5, the window has a middle time period, so each smoothed value can be placed exactly on one of the original periods.

How many moving averages can I calculate?

With n values and a k-point window you get n - k + 1 smoothed values. For example, 12 quarterly values smoothed with a 5-point moving mean give 8 moving means.

What formula do I use in a spreadsheet?

If the data are in column B, a 3-point moving mean centred on row 3 is =AVERAGE(B2:B4), and a 5-point moving median centred on row 4 is =MEDIAN(B2:B6). Fill the formula down the column.