All subjects · Mathematics · WST01 (S1)

Coding

Coding transforms data with a linear rule to make the numbers easier. You must then turn the coded mean and standard deviation back into the original units.

The rule

If y = (x - a)/b then

Adding or subtracting a constant shifts the data but does not change the spread. Multiplying or dividing scales the spread.

Using coded summary statistics

If y = (x - 50)/5 and n = 20, Σy = 36, Σy2 = 98:

ȳ = 1.8, σy2 = 98/20 - 1.82 = 1.66, σy = 1.2884.

Then x̄ = 5(1.8) + 50 = 59 and σx = 5 × 1.2884 = 6.442.

Why code?

Coding makes large or awkward numbers (like 2015, 2018, ... or 1050, 1060, ...) small, which reduces arithmetic errors. Statistics that measure position (mean, median, quartiles) follow the full rule; measures of spread (standard deviation, range, IQR) are only affected by the scaling.

Worked example

y = (x - 50)/5. The coded data have mean 3.2 and standard deviation 1.4. Find the mean and standard deviation of x.

  1. x = 5y + 50.
  2. x̄ = 5(3.2) + 50 = 66
  3. σx = 5 × 1.4 = 7 (the +50 does not change spread)

Answer: x̄ = 66, σx = 7

Key idea: y = (x - a)/b gives x̄ = bȳ + a and σx = bσy. Shifts do not change spread.

Check yourself

  1. y = (x - 50)/5. The coded mean is ȳ = 3.2. Find x̄.
    Show answer

    66. x̄ = 5 × 3.2 + 50 = 66.

  2. y = (x - 50)/5. The coded standard deviation is 1.4. Find the standard deviation of x.
    Show answer

    7. σx = 5 × 1.4 = 7. Subtracting 50 does not affect spread.

  3. y = (x - 50)/5, n = 20, Σy = 36 and Σy2 = 98. Find the mean of x.
    Show answer

    59. ȳ = 36/20 = 1.8, so x̄ = 5(1.8) + 50 = 59.

  4. y = (x - 50)/5, n = 20, Σy = 36 and Σy2 = 98. Find the standard deviation of x. Give your answer to 3 significant figures.
    Show answer

    6.44. σy2 = 4.9 - 3.24 = 1.66, σy = 1.2884, σx = 5σy = 6.44.

  5. y = (x - 100)/10 and the variance of y is 2.5. Find the variance of x.
    Show answer

    250. σx2 = 102 × 2.5 = 250.

  6. Data have mean 1060 and standard deviation 15. They are coded by y = (x - 1000)/10. Find ȳ.
    Show answer

    6. ȳ = (1060 - 1000)/10 = 6.

  7. Every value in a data set is increased by 7. What happens to the standard deviation?
    • It increases by 7
    • It stays the same
    • It is multiplied by 7
    • It increases by 49
    Show answer

    It stays the same. Adding a constant moves every value equally, so the spread is unchanged.

Practise with instant feedback

Sources

Last updated 7 November 2026. Spotted a mistake? Tell us.