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

Standard Error

How much averages vary.

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

How much does a sample mean wobble? It depends on two things. How spread out the data is, and how big the sample is. The standard error puts both into one number.

Standard Error
From the video: Standard Error
  • How much do means wobble?
  • Spread and sample size
  • The standard error

The square root of n

The standard error of the mean is the standard deviation, divided by the square root of the sample size. Let's check it by simulation. For three sample sizes, we draw ten thousand samples, and measure how much their means vary. Run it. The formula and the simulation agree.

se.pypython
import numpy as np

rng = np.random.default_rng(1)
sigma = 8

for n in [25, 100, 400]:
    means = rng.normal(170, sigma, size=(10_000, n)).mean(axis=1)
    print(f"n={n}: simulated {means.std():.2f}, formula {sigma / np.sqrt(n):.2f}")
Output
n=25: simulated 1.59, formula 1.60
n=100: simulated 0.81, formula 0.80
n=400: simulated 0.40, formula 0.40

Four times the data

Notice something. Going from twenty five people to a hundred, four times the data, only halves the standard error. To halve it again, you need four hundred. Accuracy improves with the square root of the sample size. That's why each extra digit of precision gets expensive.

keyvalue
SEstd ÷ √n
4× datahalf the error
n = 25SE 1.6
n = 400SE 0.4

Summary

The standard error is the standard deviation divided by the square root of N. It shrinks slowly as samples grow. Next, confidence intervals.

Key takeaways
  • SE = std / √n
  • Simulation agrees
  • 4× data, ½ the error
Next up: Confidence Intervals — a range for the truth