Variance and standard deviation · Mathematics Class 11–12 | StemPy Lab
Course 17.1·Lesson 3 of 3
Variance and standard deviation
The variance is the mean of the squared distances from the mean, and the standard deviation is its square root, which has the unit of the data. The shortcut and step-deviation forms find them for big tables, and a sample is treated a little differently in A-Level, IB and AP.
about 30 min1 simulation1 practice question1 Python program5 questions to check yourself
This lesson is free to read. Enroll free to keep your place and take the tests.
Lesson 3 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
What you will be able to do
find the variance and the standard deviation of a list, a frequency table and grouped data;
use the shortcut and the step-deviation methods;
explain the difference between dividing by n and by n−1.
Squaring instead of dropping the sign
The mean deviation removes the sign by taking the absolute value. There is another way to remove it: square each deviation. Squares are always positive, and they make a large miss count much more than a small one. Take the mean of the squared deviations and you have the variance, written σ2 (sigma squared):
σ2=n∑(x−xˉ)2.
With frequencies, the variance is
σ2=N∑f(x−xˉ)2.
The variance is in squared units, so we take the square root and get the standard deviation:
σ=variance.
It has the same unit as the data. For machine A of the last lesson, the squared distances from 500 are 4,1,0,1,4, which add to 10. So σ2=510=2g2 and σ=1.41g. For machine B, the squared distances are 400,100,0,100,400, so σ2=200g2 and σ=14.14g. The ratio of the standard deviations is 10, the same as for the mean deviations.
The shortcut method
The direct method needs the mean first, and then every distance. Expand the bracket:
∑(x−xˉ)2=∑x2−2xˉ∑x+nxˉ2=∑x2−nxˉ2.
Divide by n:
σ2=n∑x2−xˉ2.
In words, the variance is the mean of the squares minus the square of the mean. For a frequency table, use N∑fx2−xˉ2. This needs only the two totals ∑fx and ∑fx2.
The step-deviation method
For grouped data with class marks far from zero, write u=hx−A with an assumed mean A and class width h. Shifting by A does not change a spread, and dividing by h divides the spread by h. So
σ2=h2[N∑fu2−(N∑fu)2].
The simulation shows why the mean is the natural centre for the variance. For any centre a,
n∑(x−a)2=σ2+(xˉ−a)2.
The first term is the variance. The second term is never negative, and it is zero only when a=xˉ. So the mean square deviation is smallest about the mean. This identity returns when we combine two groups in the next course.
A worked example with grouped data
Use the marks of 50 students once more: class marks 5,15,25,35,45,55, frequencies 4,8,15,10,7,6, and mean 30.2.
Subtract the square of the mean.30.22=912.04, so σ2=1117−912.04=204.96.
The standard deviation.σ=204.96=14.32 marks.
Now the step-deviation check, with A=25 and h=10. The values of u are −2,−1,0,1,2,3. Then ∑fu=26 and ∑fu2=116, so σ2=100[50116−(5026)2]=100(2.32−0.2704)=204.96. The two methods agree.
Same mean, different spread
Two classes both have a mean mark of 60. The marks of class A lie close to 60, and the marks of class B are spread from 20 to 100. The standard deviation tells them apart, as the mean cannot. Class A has σ=5.2 marks and class B has σ=25.8 marks.
Two dot plots on the same scale from 0 to 100, with the same mean 60 marked by a vertical line. In the top plot, class A, seven dots lie between 52 and 68, close to the mean, and the label says the standard deviation is 5.2. In the bottom plot, class B, seven dots are spread from 20 to 100, and the label says the standard deviation is 25.8.
Population and sample
Everything above treats the data as the whole group, and divides by n. This is what the Indian syllabus does. Often, however, the data are only a sample taken from a much larger population, and we want to estimate the population variance from them. A sample tends to be closer to its own mean than to the population mean, so dividing by n makes the estimate a little too small. Dividing by n−1 corrects this:
s2=n−1∑(x−xˉ)2.
A-Level, IB and AP Statistics write s for this, call it the sample standard deviation (and sometimes the unbiased estimate of the variance), and use it when the data are a sample. Calculators show σn and sn−1 as two separate keys. For a large n the two are almost equal. If a question says "the variance of the data" or "of these n numbers", divide by n. If it says "an estimate of the population variance" or "the sample variance", divide by n−1.
Practise with new numbers
Try it in Python
The program finds the variance of the grouped marks by the direct method, the shortcut and the step-deviation method. All three should give the same number.
Common mistakes
Forgetting the square root. The variance is in squared units. The standard deviation is its square root.
Subtracting the mean instead of its square. The shortcut is N∑fx2−xˉ2.
Forgetting h2. In the step-deviation method the answer is multiplied by h2 for the variance, and by h for the standard deviation.
Using n−1 when the whole group is given. Divide by n unless the question says sample.
Remember these
σ2=N∑f(x−xˉ)2=N∑fx2−xˉ2 and σ=σ2.
Step deviation: σ2=h2[N∑fu2−(N∑fu)2].
The variance is never negative, and it is zero only when all the values are equal.
Divide by n−1 for a sample, as A-Level, IB and AP do.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Find the variance and the standard deviation of 2,4,6,8,10.
For 10 values, ∑x=60 and ∑x2=400. Find the variance and the standard deviation.
Can a variance be negative? When is it exactly zero?
In a step-deviation calculation, A=40, h=10, N=30, ∑fu=6 and ∑fu2=48. Find the mean and the variance.
The values are 2,4,4,6. Find the variance of the data as a whole group, and the sample variance.
References
OpenStax, Introductory Statistics, Chapter 2, section on measures of the spread of the data (variance and standard deviation).
NCERT, Mathematics for Class XI, Chapter 13 (Statistics), section on variance and standard deviation.
Enroll free in Centre and Spread of Data
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.