Aller au contenu

Leçon 10 · Summarizing Data

Spread: Range, Percentiles and Standard Deviation

Describe how spread out data is with the range, quartiles, interquartile range, percentiles and standard deviation, and flag unusual values with care.

Two sets of numbers can have the same average and still be completely different. One bus route arrives every 10 minutes almost exactly. Another averages 10 minutes but sometimes takes 2 and sometimes 25. If you only report the average, you hide what the passengers feel most: variability. Spread describes how much values differ from each other.

Same mean, different story

Route Waiting times (minutes) Mean
A 9, 10, 10, 10, 11 10
B 2, 4, 10, 14, 20 10

Route A is predictable. Route B is not. Any good summary should show a typical value and the spread.

Range

The range is the largest value minus the smallest. For route A it is 2; for route B it is 18. It is easy to understand, but it depends only on the two most extreme values, so one odd measurement can change it completely. It also tends to grow as you collect more data.

Quartiles and the interquartile range

Sort the data and split it into four parts.

Quartiles

Q1 About 25% lie below
Median About 50% lie below
Q3 About 75% lie below
1 / 2

The interquartile range (IQR) is Q3 minus Q1. It describes the width of the middle half of the data and ignores the extreme ends, so it is resistant to outliers.

Several accepted methods exist for calculating quartiles, so two tools can give slightly different answers on small datasets. This is normal. With large datasets the differences are usually tiny.

Percentiles

The 90th percentile is a value that about 90% of the observations fall at or below. If the 90th percentile of waiting time is 18 minutes, about 9 in 10 waits are 18 minutes or less, and about 1 in 10 is longer. Percentiles are very useful for service goals, because they describe the experience of the unlucky group.

A percentile is not a score. Being at the 90th percentile on a test does not mean you got 90% of the questions right.

Python Summarize two bus routes

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Standard deviation

The standard deviation measures roughly how far values typically lie from the mean. To compute it:

  1. find the mean;
  2. find each value's difference from the mean;
  3. square the differences;
  4. average the squares (this is the variance);
  5. take the square root to return to the original unit.

For route A, the differences are -1, 0, 0, 0, 1. The squares are 1, 0, 0, 0, 1, with an average of 0.4. The square root is about 0.63 minutes.

When your data is a sample used to estimate a larger group, software usually divides by one less than the number of values (stdev in Python) instead of the count (pstdev). The sample version is a little larger. A bigger standard deviation means more spread; zero means all values are identical.

For data that is roughly bell-shaped (a normal distribution), about 68% of values lie within one standard deviation of the mean, about 95% within two and about 99.7% within three. Do not apply this rule to skewed or two-peaked data. The statistics tutorial explains the bell curve.

Flagging unusual values

A common rule of thumb marks values more than 1.5 times the IQR below Q1 or above Q3. It flags values for a closer look. It does not prove they are errors.

Python Flag values for review

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Choosing a pair

Pair a center measure with a spread measure that fits it:

Data shape Center Spread
Roughly symmetric Mean Standard deviation
Skewed or with outliers Median IQR
Service promises Median 90th or 95th percentile

Spread and decisions

Spread changes what is a good choice. If you must catch a train, you may prefer a route that is slightly slower on average but much more reliable. In manufacturing, too much variation means some parts will not fit, even if the average size is perfect. In forecasting, a wide spread tells you to prepare for a range of outcomes rather than a single number.

A worked example: promising a delivery time

A shop wants to print a delivery promise on its website. Its recent delivery times, in days, are 1, 2, 2, 2, 3, 3, 3, 4, 5 and 11. The mean is 3.6 days and the median is 3 days.

If the shop promises "3 days" just because that is the median, many customers could wait longer: here 3 of the 10 deliveries did, and in general a median can leave up to half of the values above it. A promise based on a high percentile is safer. Here 8 of the 10 deliveries took 4 days or less, and 9 of 10 took 5 days or less. "Most orders arrive within 5 days" fits these figures much better. The 11-day delivery deserves its own investigation: was it a remote address, a holiday or a lost parcel?

Ten orders are very few, so the shop should recheck the promise with more data, and again during busy seasons. Spread tells you how much room a promise needs.

Practice

For the values 5, 7, 7, 8 and 23, what are the range and the median? Which will change more if 23 becomes 9: the range or the median?

Answers: the range is 18 and the median is 7. Changing 23 to 9 cuts the range from 18 to 4, while the median stays at 7. This shows why the range reacts so strongly to a single value. The standard deviation would also fall sharply, because it uses the squared distance of each value from the mean.

Common mistakes: reporting a mean with no spread; applying the 68-95 rule to skewed data; treating a flagged value as an error without checking; and reading a percentile as a percentage score.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. What does the interquartile range measure?

    IQR is Q3 minus Q1, covering the central 50% of observations.
  2. 2. A 95th percentile response time is 4 seconds. What does it mean?

    About 5% of responses are slower than this value.
  3. 3. Two datasets share the same mean. One has a standard deviation of 1 and the other of 12. What can you say?

    Standard deviation measures variability, not the number of mistakes.
  4. 4. When is the 68-95-99.7 rule appropriate?

    It describes the normal distribution and fails for strongly skewed or two-peaked data.

Summary

  • A center without a spread tells only half the story.
  • The range is simple but fragile; the IQR resists outliers.
  • Percentiles describe how bad or good the tails are.
  • Standard deviation measures typical distance from the mean.
  • Outlier rules flag values to investigate.

Next: Reading Tables and Basic Charts

Votre progression est enregistrée dans ce navigateur. Aucun compte nécessaire.