AI Hints
Home›Data Science Tutorial›Statistics: Signal or Luck
Data Science · Lesson 13 of 101

The Central Limit Theorem

Why averages behave.

⏱ 2 min read▶ Video at 21:38🎓 Free
Watch this lesson in the Data Science courseWatch on YouTube ↗Full Data Science course

Customer spending isn't a bell curve. It's skewed, with a long tail. Yet statistics is full of bell curves. How can that work? There's a remarkable fact at the centre of the whole subject, and we can see it happen.

The Central Limit Theorem
From the video: The Central Limit Theorem
  • Spending isn't a bell curve
  • Statistics is full of them
  • A remarkable fact

Bell curves from anything

We start with very skewed data. Now take averages of groups. Just five, and then fifty. Run it. Look at the three charts. The first is lopsided. Averages of five are less so. And averages of fifty make a clear bell curve. It happens for nearly any data. That's the central limit theorem, and it's why you can use the same tools across almost all business problems.

clt.pypython
import numpy as np
import matplotlib.pyplot as plt

rng = np.random.default_rng(0)
skewed = rng.gamma(2, 2, 100000)

fig, ax = plt.subplots(1, 3, figsize=(10, 3.2))
ax[0].hist(skewed, bins=60); ax[0].set_title("One customer")
for a, n in zip(ax[1:], [5, 50]):
    means = rng.gamma(2, 2, (20000, n)).mean(axis=1)
    a.hist(means, bins=60); a.set_title(f"Average of {n}")
plt.tight_layout(); plt.savefig("clt.png", dpi=110)
print("Skewed data, yet the averages form a bell curve")
Output
Skewed data, yet the averages form a bell curve

Summary

Averages form bell curves, whatever the data looks like. So now we can put a range around any estimate. Next, the honest way to report a number.

Key takeaways
  • Averages become bell curves
  • Works for nearly any data
  • Basis of most statistics
Next up: Confidence Intervals — reporting a range, not a guess