Lesson 8 of 18

Standard Error & CLT

Standard Error

The standard error (SE) measures the variability of a sample mean. It tells you how much sample means vary from the true population mean:

ext{SE} = rac{s}{sqrt{n}}

import math, statistics

data = [1, 2, 3, 4, 5]
se = statistics.stdev(data) / math.sqrt(len(data))
print(round(se, 4))   # 0.7071

Central Limit Theorem (CLT)

One of the most important results in statistics: regardless of the shape of the population distribution, the distribution of sample means approaches a normal distribution as nn increases.

This means:

  • The mean of sample means approxmuapprox mu (population mean)
  • The std of sample means approx ext{SE} = rac{sigma}{sqrt{n}}

Implications

A larger sample size nn leads to a smaller SE and more precise estimates.

import math

# SE decreases as sample grows
sigma = 10
for n in [10, 100, 1000]:
    se = sigma / math.sqrt(n)
    print(f"n={n}: SE={round(se, 2)}")
# n=10: SE=3.16
# n=100: SE=1.0
# n=1000: SE=0.32

Your Task

Implement std_error(data) that computes the standard error of the mean (sample std divided by sqrtnsqrt{n}), returned as a float rounded to 4 decimal places.

Pyodide loading...
Loading...
Click "Run" to execute your code.