Skip to content

How spread out is it?

Range, IQR, SD, MAD and coefficient of variation, and the crucial difference between SD and SE.

Introductory ~9 min8 steps

What runs in CodeSplash

You will be able to

  • Compute and read the IQR and the SD
  • Choose a robust measure when outliers are present
  • Tell standard deviation from standard error

Read first

01

Same mean, different story

Read

Two classes both average 70. In one, everyone scored between 65 and 75. In the other, half scored 40 and half scored 100. The mean describes neither class well on its own.

Spread measures how far values sit from the center:

  • Range: largest minus smallest. One value can change it.
  • IQRInterquartile rangeThe range covered by the middle half of the data, from the 25th to the 75th percentile.: the range of the middle half.
  • Standard deviationStandard deviationThe typical distance of values from their mean, in the data's own units.: the typical distance from the mean.
  • MADMedian absolute deviationThe median distance of values from the median; a spread measure that resists outliers.: the median distance from the median.
02

Which group varies more?

Predict
Tooth growth in guinea pigs

Predict first

In ToothGrowth, which supplement's tooth lengths vary more?

Orange juiceAscorbic acidThey're the same
Reveal

The answer: Ascorbic acid

Ascorbic acid: SD 8.27, against 6.61 for orange juice. That's a reason to prefer a test that doesn't assume equal spreads.

03

When the SD lies

Read

An outlier inflates the SD, because distances are squared. In this sample with two planted outliers, the SD is 1.62, even though most values sit tightly around 10.2. Fences built from the IQR run only from 9.19 to 11.1.

When outliers are present, report the IQR or the MAD beside the SD.

04

SD or SE?

Explore

The SD describes your data. The standard errorStandard errorThe typical size of the error in an estimate, the standard deviation of its sampling distribution. describes your estimate of the mean: how much it would vary from sample to sample.

SE=sn\text{SE} = \frac{s}{\sqrt{n}}

Grow the sample and watch the SE fall. It keeps shrinking with more data, while the SD settles near the population's spread.

AExplorable · Standard error against n

How much more data does it take to halve the uncertainty of a mean?

If you quadruple the sample size, the spread of sample means becomes…

How sure?
2.0
10
Simulating…

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

05

Comparing different units

Read

The coefficient of variationCoefficient of variationThe SD as a share of the mean; compares variability across scales (only for positive, ratio-scale data). is the SD divided by the mean, so it has no units. It lets you compare the spread of a variable measured in grams with one measured in days, when both are positive and measured from a real zero.

06

Read them in the app

In the app

Descriptive statistics gives all of these, with intervals for the mean and the SD. Open Insights (⌘5) and click a column for its Statistics block, too.

Notebook exercise · ~8 min

Robust spread in code

Compute the interquartile range and a median absolute deviation that is comparable with the SD, and avoid the default that isn't.

  1. The interquartile range

    Store the IQR of x (third quartile minus first, type 7 quartiles) in iqr.

    Show a solution
    Python
    iqr = stats.iqr(x)
    R
    iqr <- IQR(x)
  2. A MAD comparable with the SD

    Store the median absolute deviation of x, scaled so it estimates the standard deviation for normal data (multiplied by about 1.4826), in mad_sd.

    Show a solution
    Python
    mad_sd = stats.median_abs_deviation(x, scale="normal")
    R
    mad_sd <- mad(x)

In the app this opens as a Python or R notebook with the sample data, and its checks mark your progress.

07

Check your understanding

Checkpoint

Check yourself

A sample of 25 values has standard deviation 10. What is the standard error of the mean?

Show the answer

Answer: 2

10/25=10/510 / \sqrt{25} = 10 / 5.

Check yourself

You want to tell readers how much individual patients varied. Which do you report?

Show the answer

Answer: a

The SE describes the precision of the mean, not patients. Reporting it in place of the SD makes the data look far tighter than they are.

Check yourself

Which measure of spread changes the least if the largest value in a sample becomes ten times bigger?

Show the answer

Answer: c

The IQR depends only on the middle half. The range and the SD both react directly to the largest value.

08

Recap

Recap
  • Report spread with the center: SD with the mean, IQR with the median.
  • Outliers inflate the SD, and the IQR and MAD resist them.
  • The SD describes data, and the SE describes an estimate.

Concepts in this lesson