Coding
Coding
(Note: This topic is Edexcel only.)
Coding is where something is done to every data value to make them easier to work with. Indeed, we can add, subtract, multiply and divide our data values, and as long as we do the same thing to each data value, the mean and standard deviation of the new set can tell us the mean and standard deviation of the original values.
There are three skills you need to know for coding.
Skill 1: Coding With Raw Data
To code a data point , we turn it into where and are of our choosing. Then we can work with our new data set to get information about our original .
Recall notation: and
To get information about from our coded set , we have the following formulas:
Example: Find the mean and variance of
If we use the coding we get , which is much easier to work with.
So, find the mean and variance of the values:
Then, find the mean of the original values:
and the variance of the original values:
So the mean and variance of is and
Skill 2: Coding With Summarised Data
We can also apply coding to simplify summarised data to calculate the mean and variance.
Example: Suppose we have and with ten data points.
The obvious coding to try is
This gives and
So, the mean and variance of the values are:
This gives results of:
and
(the variance of is the same as the variance of , since we only subtracted from each number).
Skill 3: Coding With Grouped Data
We can code grouped data by coding the midpoint and calculating all our sums with the coded midpoint, then converting back at the end.
Example: Estimate the mean and variance of the heights of the teachers at a school from the following table.
Step 1: Find the midpoints.
Step 2: Choose a suitable coding for the midpoints. Here we should go for . Now add the coded midpoints to the table.
Step 3: Proceed normally with the coded values, by adding an column and an column to the table.
Step 4: Calculate the mean and variance estimates for .
Step 5: Use the coding formulas to turn these into values for .
Coding Example Questions
Question 1: By applying a suitable coding, find the mean and standard deviation of the data set
[4 marks]
A suitable coding would be , which gives as the new data set.
is the variance, while the question asked for standard deviation.
( sf)
Question 2: From the summary statistics below, find the mean and variance of , provided that there are data points.
[2 marks]
Clearly, we should use the encoding to get:
So:
Now convert back to :
Question 3: Use a suitable encoding to estimate the mean and variance of the grouped data presented below.

[6 marks]
Step 1: Find the midpoints of each class and add them to the table.

Step 2: Choose a suitable coding. In this case, there are a few possibilities, but the one shown here is .

Step 3: Proceed to create the rest of the table, with an and an column.

Step 4: Calculate the mean and variance for .
Step 5: Convert back into values.
or to significant figures.
Specification Points Covered
L3 – Interpret measures of central tendency and variation, extending to standard deviation, be able to calculate standard deviation, including from summary statistics
L4 – Be able to clean data, including dealing with missing data, errors and outliers