Interactive statistics

56 free interactive lessons: from mean and median to A/B tests and Bayes. Drag the charts and build intuition. No sign-up.

Module 4: From sample to world

From sample to world: the central limit theorem

In the previous lesson we learned: an estimate (say, a mean) is a random variable with its own sampling distribution. Now we learn the SHAPE of that distribution for the mean β€” a surprisingly simple fact on which all further inference rests.

true mean 10.91 Β· population (skewed)2 Β· one sample (n = 10) and its meanxΜ„ = 11.13 Β· distribution of sample means β†’ a bell
Samples collected: 0n: 10Standard error Οƒ/√n β‰ˆ 3.40xΜ„ deviation from truth: 0.2

Before you are three panels. Top β€” the population: skewed, e.g. service response time (many fast requests, rare very slow ones). Middle β€” one random sample from it: its points and the green line, the sample mean xΜ„. Bottom β€” the distribution of those means, accumulating. Press "take a sample" and notice: xΜ„ almost never equals the true mean β€” it misses slightly (the deviation is shown on the right).

What it means

It is thanks to the CLT that polling 1,500 people yields a reliable estimate of a whole country's mood β€” no need to ask everyone. A random sample's mean is predictably close to the truth.

And the larger the sample, the narrower the error bell, i.e. the more precise the estimate β€” which is why sample size is always center stage.

Where it shows up

Quality control checks the mean of 30 parts, not the whole batch. Ratings and indexes average samples. All of it works because means behave predictably.

A/B tests compare the means of two user groups β€” and lean on exactly this fact about the behavior of means.

Definitions
Population
all the objects we want to conclude about (e.g. all users).
Sample
a randomly selected part of the population that we actually observe.
Central limit theorem (CLT)
the distribution of the means of random samples tends to normal (a bell) β€” even if the data itself is not normal.
Standard errorΟƒ / √n
the width of the distribution of sample means: how far a sample mean typically strays from the truth. Falls like √n.
When the method lies (assumptions)

The CLT needs independent observations and finite variance. With ultra-heavy tails (a power law with Ξ± ≀ 2) the variance is infinite β€” no bell forms, and the mean does not stabilize even for large n.

With strong skew and small n the mean's distribution has not yet turned normal β€” you need a bigger sample. Dependent or clustered data (one user contributing many observations) effectively shrinks the real n.

Deep dive: the math and the mechanism (optional)

ΠŸΠΎΡ‡Π΅ΠΌΡƒ ΠΈΠΌΠ΅Π½Π½ΠΎ ΠΊΠΎΠ»ΠΎΠΊΠΎΠ»? Π‘Ρ€Π΅Π΄Π½Π΅Π΅ β€” это сумма n нСзависимых Π²ΠΊΠ»Π°Π΄ΠΎΠ², дСлённая Π½Π° n. КаТдоС наблюдСниС тянСт срСднСС Ρ‚ΠΎ Π²Π²Π΅Ρ€Ρ…, Ρ‚ΠΎ Π²Π½ΠΈΠ·; ΠΏΡ€ΠΈ слоТСнии эти случайныС отклонСния частично гасят Π΄Ρ€ΡƒΠ³ Π΄Ρ€ΡƒΠ³Π°, ΠΈ ΠΊΡ€Π°ΠΉΠ½ΠΈΠ΅ ΠΊΠΎΠΌΠ±ΠΈΠ½Π°Ρ†ΠΈΠΈ (всС наблюдСния Ρ€Π°Π·ΠΎΠΌ большиС) астрономичСски Ρ€Π΅Π΄ΠΊΠΈ β€” поэтому Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ кучкуСтся Ρƒ Ρ†Π΅Π½Ρ‚Ρ€Π° симмСтрично. Π£Π΄ΠΈΠ²ΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎ Ρ‚ΠΎ, Ρ‡Ρ‚ΠΎ Ρ„ΠΎΡ€ΠΌΠ° исходных Π΄Π°Π½Π½Ρ‹Ρ… ΠΏΡ€ΠΈ этом ΠΏΠΎΡ‡Ρ‚ΠΈ Π½Π΅ Π²Π°ΠΆΠ½Π°: складывая ΠΌΠ½ΠΎΠ³ΠΎ нСзависимых Π²ΠΊΠ»Π°Π΄ΠΎΠ², ΠΌΡ‹ всСгда ΠΏΡ€ΠΈΡ…ΠΎΠ΄ΠΈΠΌ ΠΊ Π½ΠΎΡ€ΠΌΠ°Π»ΡŒΠ½ΠΎΠΉ Ρ„ΠΎΡ€ΠΌΠ΅.

ΠžΡ‚ΠΊΡƒΠ΄Π° √n: диспСрсии нСзависимых ΡΠΊΠ»Π°Π΄Ρ‹Π²Π°ΡŽΡ‚ΡΡ (ΠΈΠ· ΠΏΡ€ΠΎΡˆΠ»ΠΎΠ³ΠΎ ΡƒΡ€ΠΎΠΊΠ°), поэтому Var(суммы) = n·σ², Π° Π΄Π΅Π»Π΅Π½ΠΈΠ΅ Π½Π° n ΡƒΠΌΠ΅Π½ΡŒΡˆΠ°Π΅Ρ‚ Π΄ΠΈΡΠΏΠ΅Ρ€ΡΠΈΡŽ Π² nΒ² Ρ€Π°Π· β†’ Var(срСднСго) = σ²/n, ΠΈ Οƒ(срСднСго) = Οƒ/√n. ΠšΠΎΡ€Π΅Π½ΡŒ β€” прямоС слСдствиС Ρ‚ΠΎΠ³ΠΎ, Ρ‡Ρ‚ΠΎ ΡΠΊΠ»Π°Π΄Ρ‹Π²Π°ΡŽΡ‚ΡΡ ΠΈΠΌΠ΅Π½Π½ΠΎ диспСрсии (ΠΊΠ²Π°Π΄Ρ€Π°Ρ‚Ρ‹), Π° Π½Π΅ сами разбросы.

Next β†’
Enjoying the materials?

This site is built by the DataSlice Telegram channel: data analytics in plain words β€” real cases, metrics, careers. The channel is in Russian.

Open the Telegram channel