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
Comparing movie ratings
0 of 2
1
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.
Explanation
There’s no single required description. If you noticed that the sets
can resemble one another in some ways and look quite different in
others, you’ve found the issue to keep hold of. We’ll put it into more
precise terms after the next question.
2
Suppose you’re about to watch each movie and add your own review.
What rating would you predict you’ll give each one? Explain what in the
existing ratings would make you more or less confident in those
predictions.
Answer
A reasonable prediction is 5 for each movie because all three have a
mean and median of 5. But I would be most confident about Fine,
Actually, where every rating so far is 5, and least confident about
The Polarizing Express, where every rating is far from 5.
The Good, the Bad and the Okay sits somewhere in between.
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. If we plot the ratings as block histograms, we can see what they’re leaving out.
Figure 4.1: Some fake reviews for three fake movies.
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 it’s 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 might make us wonder why part of the response scale went unused. 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.
Astronomers realized this too. Deviations offered a way to quantify the imprecision of 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, an obvious solution would be to calculate the average of all the deviations. Before we go any further, think through what answer that calculation would give us.
Why can’t we simply average the raw deviations from the mean?
Answer
The mean is the balance point of the distribution, so the negative
deviations below it and the positive deviations above it balance each
other out. The signed deviations therefore always add up to zero. Their
average would be zero too, no matter how much the scores varied.
Quiz 4.2
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 solves the problem by turning the negative deviations into positive values, so they no longer cancel out the deviations above the mean when we sum them.1
Having squared the deviations, we can continue 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\)).
Table 4.1: Summary and notation for calculating population variance and standard deviation.
Step
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, following that sequence of five steps; 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 - \mu\) and \((X - \mu)^2\).
Hint 2
Add the squared deviations, divide by \(N =
6\), and take the square root.
Answer
4.69
Explanation
The mean rating is \(\mu = 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}
\]
Order of operations is important here. For the first term, \(\Sigma X^2\), square every score and sum 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 in Activity 4.1 following the definitional approach. 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.
Like I mentioned in Chapter 1, there’s overlap between descriptive and inferential statistics. Here, we want to know our sample’s variance, but not because we especially care about the sample itself. Rather, we want to use it as an estimate of the population variance. The trouble is that if we used precisely the calculation above, dividing \(SS\) by \(n\), the estimate would be biased.
Bias does not mean that any one sample estimate is wrong: a sample’s variance can over- or underestimate its population variance. Bias is a long-run tendency. An unbiased estimator is sometimes too high, sometimes too low, but those errors balance out in the long run. A biased estimator systematically leans in one direction. If we repeatedly took samples and calculated variance by dividing \(SS\) by \(n\), the average of all the estimates would be less than 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 minimize their sum of squared deviations. As a result, the sum of squared deviations around \(M\) can never be larger than the sum of squared deviations of those same scores around \(\mu\), and will be smaller unless \(M = \mu\).
Activity 4.2: The moving center
Interactive sampling diagram comparing the same sample's deviations around its fitted mean and the fixed population mean.
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.
The adjusted denominator makes sample variance, \(s^2\), an unbiased estimator of population variance. Taking its square root gives the usual sample standard deviation, \(s\), often labeled \(SD\) when results are reported in psychology.3
Here is the table of steps and equations again, with a new column applying them to samples. There are differences in notation—the Greek symbols \(\mu\) and \(\sigma\) and uppercase \(N\) for populations; \(M\), \(s\), and \(n\) for samples. But aside from the different denominator in step 4, the process is the same.
Table 4.2: Summary and notation for calculating population and sample variance and standard deviation.
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}\)
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 \(s^2 = 52 / 5\), then take
the square root.
Answer
3.22
Explanation
\(s^2 = SS / (n - 1) = 52 / 5 =
10.4\). Its square root, the sample standard deviation, is about
3.22.
Degrees of freedom
Well, it’s not quite as simple as I made it sound there. To fully understand the issue and why this solution works, we need to know about \(df\), which I snuck into Table 4.2. That refers to degrees of freedom. For ordinary sample variance, \(df = n - 1\). More generally, a variance is a sum of squares divided by the degrees of freedom associated with it, and \(df\) is not always \(n - 1\) as it is in this case. Later, in ANOVA, we’ll split variability into several sums of squares, each with its own \(df\).
So why does the correction here use exactly \(n - 1\)? It is a result of the constraint imposed by calculating deviations from the sample mean. Doing so costs us one degree of freedom.
To illustrate, suppose I put a sample of three playing cards face down in front of you and tell you that I already calculated the mean of their values, \(M=5\). I point to the first card and ask you what number you think it is. There is no way for you to know, of course, so you shrug and I show you that it is a three. I point to the second card. You still can’t know what it is; I turn it over and reveal a five. Now I point to the last card. Can you tell me its number? You jump up and exclaim, “eureka!” Given the mean and the other two values, there’s only one thing this last one can be: it has to be seven.
Three cards: the 3 of clubs and 5 of hearts are face up; the last card is face down. With a mean of 5, its value must be 7.
We could shuffle the same three cards and repeat the process; the order the cards are turned over in doesn’t matter. And we could have more than three cards. Whatever the last card is, we’ll always be able to determine its value without turning it over. Knowing 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 calculated, 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. (Later we’ll meet calculations that fit more means and therefore have different degrees of freedom.)
Note that this problem is specific to the sample mean, \(M\). If the population mean, \(\mu\), were known and we measured the sample’s deviations around that fixed population center, we would not lose a degree of freedom. That known \(\mu\) is a constant, not something we estimate from the sample data, and so it does not impose the constraint of deviations summing to zero.
Sampling error and statistical bias
One last thing. Now that you know about statistical bias, you might be worried about other statistics being biased. What about the mean? We spent most of Chapter 3 talking about it, but never mentioned bias. It shouldn’t get off the hook, right? We ought to check if it is biased or unbiased. And turning back to variance, Activity 4.2 illustrated the cause of its bias, but it only showed one sample at a time. Like we said, bias operates in the aggregate.
It would help to be more precise about the term error. An estimate can differ from the true parameter for different reasons. Sometimes it is thrown off by a genuine mistake or a bad design choice. But even under ideal circumstances, a statistic calculated from one sample will usually not be exactly equal to the corresponding population parameter. This kind of naturally-occuring discrepancy between the estimate and the true parameter, is called sampling error. It’s not an error in the colloquial sense of something we did wrong and could have avoided. It is inherent to the process of sampling from a population.
Bias, by contrast, is a long-run property. Across repeated samples, do a statistic’s errors balance around zero, or do they systematically lean in one direction? Being unbiased doesn’t mean every estimate gets the answer exactly right; sampling error means each individual estimate can still be above or below the true parameter. But it makes the overestimates and underestimates balance out in the long run. To see the difference between sampling error and bias, we need to look at many estimates. Let’s check for bias in the mean, as well as in the two variance calculations.
Activity 4.3: Tracking bias across repeated samples
Interactive charts tracking mean and variance estimates across repeated samples.
So phew, by taking a whole bunch of samples and aggregating their errors, we can see that the sample mean is an unbiased estimator of the population mean.4 It doesn’t always get the answer exactly right. Individual samples can overestimate or underestimate the true population mean, because of ever-present sampling error. But in the long run those random errors balance out and the mean is unbiased.
Sample variance can be an unbiased estimator of population variance too, as long as we divide \(SS\) by \(df\) (\(n - 1\) in this situation). Dividing by \(n\) does not stop the estimates from varying randomly; it shifts their long-run center downward. Individual estimates can still be too high or too low, but their errors average below zero, as we saw in the cumulative average of the 1,000 variance estimates calculated with the uncorrected denominator. The green line, where we divided by \(n - 1\), fluctuated along the way but made its way close to zero in the long run.
Learning Checks
0 of 6
1
Two datasets both have a range of 10. Which conclusion can you draw
from that information alone?
Answer
Only the maximum-minus-minimum difference is the same.
Explanation
The range uses only the distance between the minimum and maximum. It
does not tell us where those extremes fall or how any of the scores
between them are distributed.
2
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.
3
A set of response times is measured in seconds. What units would its
variance and standard deviation use?
Answer
Variance in seconds squared; standard deviation in seconds
Explanation
Variance is the mean squared deviation, so its units are
squared too. Taking the square root gives standard deviation in the
original units.
4
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, \(s^2 = SS / (n - 1) = 24 / 3
= 8\). Dividing by \(n\) instead
of \(n - 1\) would give the biased
answer of 6.
5
A random opinion poll estimates 48% support for a proposal, while the
true population value is 50%. The same polling procedure produces
estimates centered on 50% across many random samples. How should we
describe the two-percentage-point discrepancy in the first poll?
Answer
It is sampling error, but the polling estimator is unbiased.
Explanation
One random sample can miss its population parameter even when nothing
has gone wrong. That discrepancy is sampling error. Bias is a long-run
tendency, and the estimates balancing around 50% tell us that this
estimator is unbiased.
6
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 squaring has some other mathematical properties that will become useful when we get around to partitioning variance later in the book. As usual, 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\).↩︎
More precisely, the sample mean is an unbiased estimator of the population mean under the random-sampling setup used here. Bias can be introduced in other ways, but that’s an issue for another time.↩︎