Animated family of normal curves showing different standard deviations.
In the previous chapter we talked about measures of central tendency. But there is another crucial characteristic of distributions that we need to know in addition to the center: how widely scattered or closely clustered scores are around it. That’s what we mean by variability. We’ll start with the range, then build up the standard deviation from deviations, sums of squares, and variance. Along the way we’ll meet another important concept: degrees of freedom.
What is variability?
To start with, let’s consider a few small sets of scores. Imagine you check the reviews of three movies you’re thinking about watching, scored from 0 to 10.
Fine, Actually: 5, 5, 5, 5, 5, 5
The Good, the Bad and the Okay: 0, 4, 5, 5, 6, 10
The Polarizing Express: 0, 0, 1, 9, 10, 10
How might you describe the differences among these sets of ratings? Don’t worry about calculating any new statistics yet. Start with the ideas from the previous chapter and think about what they capture or leave out.
Comparing reviews
How would you describe the differences among the three sets of
ratings above? Suppose another person reviews each movie. If you had to
predict each rating using a single number, what would you predict? Would
you trust all three predictions equally? What do the measures of central
tendency from the previous chapter capture or leave out?
Answer
All three sets have the same median and mean: 5. The first two also
have a mode of 5, whereas The Polarizing Express has two modes, 0 and
10. The ratings for Fine, Actually are all identical. Most ratings for
The Good, the Bad and the Okay cluster near 5, while those for The
Polarizing Express are spread towards the extremes. A rating of 5 would
be a sensible single-number prediction for each movie, but we would
trust that prediction most for Fine, Actually and least for The
Polarizing Express.
Explanation
The mean and median can give us the same single-number prediction for
distributions whose scores differ substantially in how closely they
cluster around it. The modes for The Polarizing Express hint at its
split ratings, but a measure of variability lets us quantify the
difference in spread.
Quiz 4.1
Using the tools we explored in the previous chapter, we find that the median and mean are 5 for all three movies. The mode is also 5 for the first two. The Polarizing Express has two modes, 0 and 10, which already gives us a clue that something different is going on. But none of these measures quantifies just how closely the ratings cluster around the center. Without knowing anything else about the movies, if you were to try to guess how much you will like each one — what score will you most likely give it? — 5 would be a sensible prediction in each case. But it seems a more reliable guess in some cases than others. If we plot the ratings as block histograms, we can see why.
Block histogram of ratings for Fine, Actually, all at 5.
Block histogram of ratings for The Good, the Bad and the Okay, mostly clustered around 5 with ratings at 0 and 10.
Block histogram of ratings for The Polarizing Express, clustered near 0 and 10.
The ratings for Fine, Actually do not vary at all: every reviewer so far gave it a 5. Most of the ratings for The Good, the Bad and the Okay cluster in the middle, aside from the two extremes. The ratings for The Polarizing Express sit much farther towards the extremes, with none in the middle of the scale at all. So Fine, Actually has no variability, The Polarizing Express has relatively high variability, and The Good, the Bad and the Okay sits somewhere in between. The mean gives us the same prediction for all three, but their variability tells us how far individual ratings tend to depart from it.
How do we quantify that difference? Like measures of central tendency, measures of variability use a single number to summarize a more complex dataset. But this time we’re describing spread rather than center. Greater variability means scores are more widely dispersed, so the center by itself tells us less about what any individual score is likely to look like. And, as with central tendency, there is more than one way to quantify it.
The range
Remember Hipparchus? I mentioned him in Chapter 3 as an early astronomical pioneer, gazing at the heavens, taking measurements, and realizing that his data were not always perfectly consistent. His solution (according to later sources; his own original work is mostly lost) was to take the midrange: the halfway point between the lowest and highest observations (Stahl, 2006).
The utility of this to the early astronomers was to smooth over the discrepant measurements; once the midrange was calculated it could be taken as providing a reliable answer, and the extremes could be largely ignored. But those two values also offer a simple and intuitive way of quantifying variability: the range, calculated by subtracting the minimum score from the maximum.
The range captures one important difference: it is zero for Fine, Actually because its ratings don’t vary. But it gives us the same answer for The Good, the Bad and the Okay and The Polarizing Express. There’s nothing wrong about that. The range is telling us precisely what it is designed to, but it misses the obvious difference between how the ratings are distributed between the extremes.
This is the main limitation of the range as a measure of variability: it does not consider all the observations. Only the two extremes contribute to its value. As a result, it is not affected by how observations are distributed between them. This characteristic also makes it highly susceptible to outliers. One unusual observation can drastically change the range. It also tends to grow with sample size, simply because larger samples have more opportunities to include extreme values.
That’s not to say looking at the range isn’t useful for some purposes. Researchers often begin by checking the minimum, maximum, and range to get a quick sense of the values in their data. Sometimes you just don’t know what to expect, so its helpful to see the extremes and how far apart they are. It can also reveal a problem. Suppose we write a new extraversion item that allows responses numbered one to five. A range of three suggests that the item didn’t work well. Maybe asking people “Are you the world’s most extraverted person?” was a bit too much and restricted the range of responses. A range of ten, on the other hand, tells us to check for misrecorded values.
Useful as the range is, we also want a measure of variability that considers every observation, not just the two extremes. For that, we need a more mathematically sophisticated measure.
Deviations
In chapter 3 we introduced deviations: the differences between each score and the mean. The mean is the point at which those deviations balance, but the deviations themselves also give us a way to quantify how far the scores spread around it.
For astronomers, deviations offered a way to quantify measurement error: imprecision in their instruments or observations. For statisticians applying the same ideas to human measurements, they captured a different kind of variation. In Quetelet’s measurements of soldiers’ chests, a deviation did not necessarily indicate a mistake of the measuring tape; it described how one person’s body differed from another’s. In either case, if we think of the mean as a prediction, a deviation is the prediction error: how far, and in which direction, the actual score fell from it.
The next step was to find a way to summarize those deviations in a single number. Should be easy, no? If we want a “standard deviation,” meaning a typical deviation from the mean, why not just calculate the average of all the deviations?
Average of Deviations
Why can we not simply average the raw deviations from the mean to
measure variability?
Answer
The raw deviations from the mean always sum to zero because the mean
is the balance point of the distribution.
Explanation
To measure typical distance from the mean, we need to stop positive
and negative deviations from canceling out. Squaring deviations is the
usual solution.
Quiz 4.2
The problem is that, precisely because the mean is the balance point, the deviations above and below balance each other out. To find a mean, we first have to add the values up, but the signed deviations always add up to zero. That means it’s not possible to calculate an average deviation this way. The answer would always be zero.
So we need a different strategy. One option would be to take the absolute value of every deviation, dropping the minus sign from the negative ones, and then find the mean absolute deviation. But the strategy we’re going to focus on is squaring each deviation. Squaring makes all the deviations nonnegative and has other mathematical properties that will become useful when we minimize and partition variance later.1
Having squared the deviations, we can follow up with one connected chain of calculations. Add the squared deviations to get \(SS\), the sum of squared deviations (or “sum of squares” for short). Divide \(SS\) by the number of observations to get the population variance, the mean squared deviation. Then take its square root to get the standard deviation. The square root returns us to the original units, so we can interpret the standard deviation as a typical deviation from the mean.2
Variability equations for populations
To complicate life slightly, populations and samples use slightly different calculations. We’ll start with a population and return to samples shortly.
The table puts the steps into mathematical notation. Population variance is represented by lowercase sigma squared (\(\sigma^2\)), and population standard deviation by lowercase sigma (\(\sigma\)).
Step
Population calculation
1. Find the deviation for each score
\(X - \mu\)
2. Square the deviations
\((X - \mu)^2\)
3. Sum the squared deviations
\(SS = \Sigma(X - \mu)^2\)
4. Calculate variance (mean squared deviation)
\(\sigma^2 = \frac{SS}{N}\)
5. Calculate standard deviation (root-mean-square deviation)
\(\sigma = \sqrt{\sigma^2}\)
Equations in hand, let’s return to the two movies whose ratings had the same range. For now, we’ll treat each complete set of ratings as its own population. We’ll work through The Good, the Bad and the Okay together; then you can try the same procedure for The Polarizing Express.
Activity 4.1: Calculate variability
Interactive table calculating deviations, sum of squares, variance, and standard deviation for the ratings of The Good, the Bad and the Okay.
Now calculate variability for The Polarizing Express
Follow the whole procedure for the ratings of The Polarizing Express:
0, 0, 1, 9, 10, and 10. Treating these six ratings as a population, what
is the standard deviation?
Hint 1
Start by finding the mean. Then make columns for X − μ and (X − μ)2.
Hint 2
Add the squared deviations, divide by N = 6, and take the square root.
Answer
4.69
Explanation
The mean rating is μ = 5.
Here is the whole calculation:
Filled variability table for the ratings of The Polarizing Express,
showing deviations, squared deviations, SS = 132, population variance =
22, and population standard deviation = 4.69.
Taking the square root of 22 gives a standard deviation of 4.69. This
is larger than the 2.94 for The Good, the Bad and the Okay, capturing
the greater spread that the range missed.
Quiz 4.3
The importance of sums of squares
Allow me for a moment to impress upon you the importance of squares. \(SS\) is not just an intermediate answer that we can forget about as soon as we’ve found the standard deviation. Later in this book we’ll find ourselves splitting variability into different sources, each with its own sum of squares. By the time we finish ANOVA and regression near the end of the semester, I like to joke with my students that the whole course has been nothing but squares all the way down.
The tables above followed the definitional formula for \(SS\): find each deviation, square it, and add the squared deviations.
\[
SS = \Sigma(X - \mu)^2
\]
There is an algebraically equivalent shortcut called the computational formula:
\[
SS = \Sigma X^2 - \frac{(\Sigma X)^2}{N}
\]
For the first term, square every score and add the results. Then subtract the correction term: the sum of the scores squared, divided by the number of scores. For The Good, the Bad and the Okay, \(\Sigma X=30\) and \(\Sigma X^2=202\), so:
\[
SS = 202 - \frac{30^2}{6} = 202 - 150 = 52
\]
That is the same answer we found by calculating every deviation. The shortcut likewise gives \(SS=132\) for The Polarizing Express, so the rest of both calculations remains unchanged.
We’ll stick with the definitional approach for now, but tuck this computational arrangement in the back of your mind; it will become our preferred method when we get to the ANOVA section of the book.
Sample variability and bias
So far we’ve treated the movie ratings as populations. I mentioned that we have to do things a little differently for samples. Don’t worry, the difference in the math is tiny, but the reason for it is important.
In research, we generally use the limited information in a sample to estimate something about a population. Here, we want sample variance to estimate population variance. But if we used precisely the calculation above, dividing by \(n\), the estimate would be biased. Bias does not mean that any one sample estimate is wrong: a single sample variance can fall above or below the population variance. It is a long-run property. An unbiased estimator is sometimes too high, sometimes too low, but those errors balance out in the long run. A biased estimator still sometimes misses high, sometimes low, but in the long run it systematically leans more in one direction than the other. If we repeatedly took samples and calculated variance by dividing \(SS\) by \(n\), the estimates would average below the actual population variance; it would underestimate the true value.
The bias comes from using the sample mean, \(M\), in place of the unknown \(\mu\). Each sample’s \(M\) is fitted to the scores in that particular sample, designed to minimizes their sum of squared deviations. As a result, the sum of squared deviations around \(M\) can only be smaller than the sum of squared deviations of those same scores around \(\mu\), never larger.
Activity 4.2: The moving center
Interactive height-sampling diagram showing each uncorrected sample SD first centered on its fitted sample mean, then shifted to the fixed population mean for comparison.
Variability equations for samples
So now we know what the problem is, here’s the solution: divide \(SS\) by \(n - 1\) rather than \(n\). If only all of life’s problems were so easily solved.
Here is that correction in context. A population uses the known \(\mu\) and divides \(SS\) by \(N\); a sample uses its fitted \(M\) and divides by \(n - 1\). Apart from the fitted center, denominator, and notation, the steps are the same.
Step
Population
Sample
1. Find the deviation for each score
\(X - \mu\)
\(X - M\)
2. Square the deviations
\((X - \mu)^2\)
\((X - M)^2\)
3. Sum the squared deviations
\(SS = \Sigma(X - \mu)^2\)
\(SS = \Sigma(X - M)^2\)
4. Calculate variance
\(\sigma^2 = \frac{SS}{N}\)
\(s^2 = \frac{SS}{df} = \frac{SS}{n - 1}\)
5. Calculate standard deviation
\(\sigma = \sqrt{\sigma^2}\)
\(s = \sqrt{s^2}\)
This correction makes \(s^2\) an unbiased estimate of population variance. Taking its square root gives the usual sample standard deviation, \(s\), often labeled \(SD\) when results are reported in psychology.3
From population to sample
Now suppose the six ratings for The Good, the Bad and the Okay are a
sample from the larger population of ratings that viewers might give it.
Earlier, you found that SS = 52. What is the sample
standard deviation?
Hint 1
You do not need to calculate the deviations or SS again. Pick up at the
step where the sample calculation differs from the population
calculation.
Hint 2
For n = 6, the degrees of
freedom are n − 1 = 5. First
calculate s2 = 52/5, then take the
square root.
Answer
3.22
Explanation
s2 = SS/(n − 1) = 52/5 = 10.4.
Its square root, the sample standard deviation, is about 3.22.
Degrees of freedom
But wait, why does the correction use exactly \(n - 1\)? Suppose I have put three playing cards face down in front of you and tell you that their mean is \(M=5\). There is no way to know the value of the first card, so I show you that it is a three. There is still no way to know the second; it turns out to be a five. But you can now tell me the value of the third card. Given the mean and the other two values, it has to be seven.
🃓 🂵 🂠
We could shuffle the same three cards and repeat the process; the order the cards are turned over in doesn’t matter. Whatever the last card is, we’ll always be able to determine its value without turning it over. Fixing the mean imposes a constraint. Only two of the three values are free to vary. The same applies to deviations around the sample mean: once \(M\) has been fitted, the deviations have to sum to zero. Any \(n - 1\) deviations can vary, but their values determine the last one. So sample variance has \(df = n - 1\)degrees of freedom.
If \(\mu\) were already known and we measured the sample’s deviations around that fixed population center, they would not be constrained to sum to zero and we would not lose a degree of freedom by fitting \(M\). (Later we’ll meet calculations that fit more means and therefore have different degrees of freedom.)
Visualizing statistical bias
The moving-center visualization showed the mechanism within each sample. But bias is a long-run property, so now we need to follow estimates across many samples. There is no contradiction in saying that \(M\) is an unbiased estimate of \(\mu\) while fitting \(M\) creates bias in \(SS/n\). Across samples, the errors in \(M\) balance around zero. Within each sample, \(M\) is the center that minimizes \(SS\).
Activity 4.3 tracks both the individual errors and their cumulative average. We will begin with the sample mean, then compare variance calculated using \(SS/n\) and \(SS/(n - 1)\).
Activity 4.3: Tracking bias across repeated samples
Interactive charts tracking mean and variance estimates across repeated samples.
The two charts distinguish sampling error from bias. The wide vertical scatter in the upper chart is sampling error: estimates differ from sample to sample. The long-run position of the lower line is bias. Neither using the mean nor dividing variance by \(n - 1\) makes every estimate accurate; it makes the overestimates and underestimates balance out on average.
Learning Checks
0 of 4
1
Is it possible for a sample to have a standard deviation of zero?
Answer
True
Explanation
A standard deviation of zero occurs when every score has the same
value.
2
A sample has 4 scores. What is the number of degrees of freedom for
calculating sample variance?
Answer
3
Explanation
For sample variance, df = n - 1 = 4 - 1 = 3.
3
A sample of four scores has SS = 24. What is the
variance?
Hint 1
Sample variance is SS divided by its degrees
of freedom.
Hint 2
For a sample, the number of degrees of freedom is n − 1.
Answer
8
Explanation
For a sample, s2 = SS/(n − 1) = 24/3 = 8.
Dividing by n instead of n − 1 would give the biased answer
of 6.
4
Why do we divide SS by n − 1 rather than n when estimating population
variance from a sample?
Answer
The sample mean, M, is
fitted from the same scores and minimizes their sum of squared
deviations. Dividing that reduced SS by n therefore underestimates
population variance on average. Dividing by n − 1 corrects the bias.
Explanation
Missing rare or extreme scores cannot by itself explain systematic
bias: some samples overestimate variability, and others underestimate
it. The downward bias comes from centering every sample on its own
fitted mean. The n − 1
denominator is the degrees-of-freedom correction for sample
variance.
The mean absolute deviation from the mean is a perfectly legitimate measure of variability, and it is less affected by extreme scores because it does not square their distances. But statistics don’t invent and apply themselves: we still have to think about which measure makes the most sense for what we’re trying to do.↩︎
More precisely, the population standard deviation is the root-mean-square deviation: we square the deviations, find their mean, and take the square root. “Typical deviation” is a useful interpretation, but it isn’t the literal arithmetic mean of the raw deviations or their absolute values. I don’t hear social scientists use the term “root-mean-square deviation” very often, so I’m just going to follow the convention of calling it the standard deviation.↩︎
Strictly speaking, taking the square root introduces a small downward bias, especially with very small samples. But \(s\) is much less biased than an uncorrected standard deviation based on \(SS/n\).↩︎