AI Hints
Statistics & Math for ML · Lesson 13 of 138

Why Spread Matters

Same mean, different data.

⏱ 2 min read▶ Video at 13:38🎓 Free
Watch this lesson in the Statistics & Math for ML courseWatch on YouTube ↗Full Statistics & Math for ML course

Two cities both have an average temperature of twenty degrees. In one, every day is about twenty. In the other, some days freeze and some days roast. Same average, very different places to live. The average alone hides that. We also need the spread.

Why Spread Matters
From the video: Why Spread Matters
  • Same average: 20 degrees
  • One is steady, one is wild
  • We need the spread

Same mean, different spread

Here are five days in each city. The means are both twenty. The range is the simplest measure of spread. The largest value, minus the smallest. Run it. City A has a range of two degrees. City B has a range of thirty.

cities.pypython
import numpy as np

a = np.array([20, 21, 19, 20, 20])
b = np.array([5, 35, 10, 30, 20])

print("means:", a.mean(), b.mean())
print("range A:", a.max() - a.min())
print("range B:", b.max() - b.min())
Output
means: 20.0 20.0
range A: 2
range B: 30

The trouble with range

The range is easy, but it only looks at two values, the most extreme ones. One strange day can make it huge. So statisticians usually prefer measures that use every value, like the variance and the standard deviation. That's next.

keyvalue
Rangemax minus min
Easyone subtraction
Weaknessonly two values count
Bettervariance, standard deviation

Summary

Averages tell you the centre, and spread tells you how far values wander from it. The range is the simplest spread. Next, the variance.

Key takeaways
  • Same mean, different data
  • Range = max - min
  • Range uses only extremes
Next up: Variance — average squared distance