Distributions and the central limit theorem

55 min7 partsFoundationFundamentalsChecked Dec 2026
Start the lessonShort steps, each with something to do
What you'll learn
  • Work out a distribution's mean and variance, and derive the uniform's in an interview
  • Pick the distribution that fits a count, a wait or a yes-or-no, and know its mean and variance
  • Explain why an average's spread shrinks with the square root of n, and size n for a target
  • State the central limit theorem, and show it with a simulation
  • Spot the metrics where the CLT is slow, and what to do about them

Means, variances and the CLT, the way the statistics round asks

A Netflix data science candidate reports a statistics question on the central limit theorem and on the mean and variance of a uniform distribution (1 report). This lesson's practice problem puts that question in code, in three levels:

  1. uniform_moments(a, b), die_moments(n) and moments(values, probs): the mean and variance of a uniform, a fair die and any discrete distribution.
  2. standard_error(sd, n), n_for_standard_error(sd, target) and prob_mean_above(mu, sd, n, threshold): how an average of n draws spreads, how much data a target needs, and the central limit theorem's chance of a high average.
  3. skewness(xs), users_for_normal_mean(skew) and covers(xs, mu): how lopsided data are, how many users a skewed metric needs, and whether the usual interval contains the truth.
CallReturns
uniform_moments(0, 12)(6.0, 12.0)
die_moments(4)(2.5, 1.25)
prob_mean_above(10, 2, 16, 11)0.0228
users_for_normal_mean(4)5,680

The lesson follows the shop's deliveries and orders: the mean and the variance, five common distributions, the standard error, the central limit theorem, and the skewed metrics it handles slowly. Six steps end with a small task in the editor.

Part 1 of 7about 14 min
Mean and variance

Every random quantity has a center and a spread

A Netflix data science candidate reports a statistics question on the central limit theorem and on the mean and variance of a uniform distribution (1 report). Both rest on two numbers that describe any random quantity:

  • The mean, or expected value, is its long-run average.
  • The variance is the average squared distance from the mean. Its square root, the standard deviation, is back in the original units.

For a list of values with their chances, the mean is each value times its chance, added up, and the variance is each squared distance from the mean times its chance, added up.

In the editor, write moments(values, probs). It prints a fair die's mean and variance.

The uniform: the midpoint, and the width squared over 12

The shop's parcels take between 2 and 6 days to arrive, and any time in that range is equally likely: a uniform distribution. NIST's handbook gives its mean as (A + B)/2, the midpoint.

Predict

Before working it out: if the delivery window doubled from 4 days wide to 8, what would happen to the variance?

Pick an answer above to see the rest
Predict

What's the variance of a delivery time that's uniform from 2 to 6 days?

Pick an answer above to see the rest
Predict

A fair die is uniform over the whole numbers 1 to 6. Is its variance 25/12, from the same formula with a width of 5?

Pick an answer above to see the rest
Part 1 done
Part 2 of 7about 3 min
Common distributions

Five distributions cover most questions

Most interview questions use one of five shapes. Guess two of their facts before the table gives them away.

Predict

Orders arrive independently at 3 a minute on average. What's the variance of the count in one minute?

Predict

At 3 orders a minute, the gap between orders averages 20 seconds. What's its standard deviation?

Pick an answer above to see the rest
Part 2 done
Part 3 of 7about 8 min
Averages

Variances add, so averages shrink by the square root of n

Grinstead and Snell put the key fact in one line: for independent random variables, the variance of the sum is the sum of the variances. An average is a sum divided by n, which divides the variance by n², so the average of n draws has variance σ²/n and standard deviation σ/√n.

That spread of an average has its own name, the standard error. OpenStax puts it this way: the standard deviation of the sampling distribution is the original standard deviation over the square root of n.

# one delivery's spread, in days
sd = (16 / 12) ** 0.5
for n in (1, 4, 16, 100):
    print(f"the average of {n:3} deliveries spreads {sd / n ** 0.5:.3f} days")
Predict

How many deliveries must you average to halve the spread of one?

Pick one to see what it prints.
Pick an answer above to see the rest
Part 3 done
Part 4 of 7about 9 min
The central limit theorem

Averages of many draws are close to normal, whatever one draw looks like

NIST's handbook states the central limit theorem: as the sample size grows, the sampling distribution of the mean becomes approximately normal, regardless of the distribution of the original variable. Its center is the mean μ, and its spread is the standard error σ/√n. OpenStax adds a point people trip on: n is the number of values averaged, not the number of times the experiment is run.

Abraham de Moivre first proved it for coin-flip trials, in a book from 1718. Try it here: start with one delivery, then average 2, 5, 30 and 100.

The averages of n drawsInteractive
Draws averaged
23456the average of 1
3,000 simulated averages normal curve, mean μ and spread σ/√n
Mean of averages
4.05
Spread of averages
1.15
σ/√n
1.15
Skew
-0.05
Each bar counts single draws of the delivery time, uniform from 2 to 6 days. They spread 1.15 around 4.05, close to σ/√n = 1.15, and their shape is not normal yet.
Predict

A single delivery is flat from 2 to 6 days. What does the average of 30 deliveries look like?

Pick an answer above to see the rest
Predict

What share of the averages of 30 deliveries should land within 1.96 standard errors of 4 days?

Pick one to see what it prints.
Pick an answer above to see the rest
Part 4 done
Part 5 of 7about 10 min
When the CLT is slow

Skewed metrics need far more data before the curve fits

Order values aren't flat. Most orders are small and a few are huge, which makes them skewed to the right. Here the widget starts on order values: at 30 orders the averages are still lopsided.

The averages of n order valuesInteractive
Draws averaged
$0$100$200$300the average of 30
3,000 simulated averages normal curve, mean μ and spread σ/√n
Mean of averages
$89
Spread of averages
$21
σ/√n
$22
Skew
0.96
Each bar counts averages of 30 draws of the order value, skewed with a long right tail. They spread $21 around $89, close to σ/√n = $22, and their shape is not normal yet.

Kohavi and colleagues found that many metrics in online experiments are skewed like this. At one commerce site, the skewness of revenue per customer was over 30. Here's how a normal 95% interval does on the shop's order values:

import numpy as np

rng = np.random.default_rng(8)
# order values: e to the power of a normal with mean 4 and sd 1
true_mean = np.exp(4.5)
for n in (30, 300, 3_000):
    x = np.exp(rng.normal(4, 1, size=(2_000, n)))
    m, s = x.mean(axis=1), x.std(axis=1, ddof=1)
    covered = np.abs(m - true_mean) < 1.96 * s / np.sqrt(n)
    print(f"n = {n:5,}: the 95% interval covers the true mean {covered.mean():.1%} of the time")
Predict

With 30 orders, how often does the usual 95% interval contain the true mean order value?

Pick one to see what it prints.

A rule of thumb: 355 times the skewness squared

The same paper gives a rule of thumb for how many independent observations each variant needs before its mean is close to normal: 355 times the skewness squared. The skewness is the average cubed distance from the mean, in standard deviations: 0 for a symmetric shape, large and positive for a long right tail.

import math

# the skewness of these order values
skew = (math.e + 2) * math.sqrt(math.e - 1)
print(f"skewness {skew:.2f}, so 355 x skewness squared = {355 * skew ** 2:,.0f} orders")
Predict

In the paper's own example, revenue per user had a skewness of about 18. Roughly how many users did the rule ask for?

Pick one to see what it prints.
Pick an answer above to see the rest
Part 5 done
Part 6 of 7about 8 min
The worked example

A worked example: the uniform and the CLT, end to end

Here's a statistics round question, worked end to end.

X is uniform from 0 to 1. What are its mean and variance? What does the CLT say about the average of 100 draws? How likely is that average to come out above 0.55?

1. Mean and variance. The mean is 1/2. E[X²] = 1/3, so the variance is 1/3 − 1/4 = 1/12.

2. The average. By the CLT, the average of 100 draws is close to normal with mean 0.5 and variance 1/12 / 100, so a standard error of 0.0289.

3. The tail. 0.55 is 0.05 above the mean, which is 1.73 standard errors.

from statistics import NormalDist

se = (1 / 12) ** 0.5 / 100 ** 0.5
z = (0.55 - 0.5) / se
print(f"standard error {se:.4f}, z = {z:.2f}, chance above z = {1 - NormalDist().cdf(z):.4f}")
Predict

How likely is the average of 100 uniform draws to come out above 0.55?

Pick one to see what it prints.
Pick an answer above to see the rest
Part 6 done
Part 7 of 7about 3 min
Follow-ups

The normal approximation to the binomial

Two follow-ups come up after this question.

The CLT also covers counts, since a count of yeses is a sum of Bernoulli trials. The shop's returns in 1,000 orders at 10% have mean 100 and standard deviation √90, about 9.5.

from math import comb
from statistics import NormalDist

exact = sum(comb(1000, k) * 0.1 ** k * 0.9 ** (1000 - k) for k in range(121, 1001))
approx = 1 - NormalDist(100, 90 ** 0.5).cdf(120.5)
print(f"exact {exact:.4f}, normal approximation {approx:.4f}")
Predict

Does the normal curve estimate the chance of more than 120 returns too high or too low?

Pick one to see what it prints.
Pick an answer above to see the rest

The law of large numbers is a different promise

The law of large numbers says the average gets close to μ. The central limit theorem says how far off it is likely to be on the way there: normally distributed errors with spread σ/√n. Interviewers like to hear you keep them apart.

The practice problem, start to finish

That's every piece the practice problem needs. It asks for the three levels from the start of the lesson, from a blank file, and the interviewer follows up after each one.

Check yourself
5 questions
  1. 1.What are the mean and variance of a uniform from 2 to 6?

  2. 2.Orders arrive independently at 3 a minute on average. What's the standard deviation of the count in a minute?

  3. 3.How much data does it take to cut an average's standard error to a tenth?

  4. 4.What does the central limit theorem say?

  5. 5.Revenue per user has a skewness of 18. What does that mean for an experiment on it?

Practice

Sources (17)
  1. 1.3.6.6.2. Uniform Distribution · NIST/SEMATECH e-Handbook of Statistical Methods · Nov 19, 2026
    “Mean (A + B)/2 Median (A + B)/2 Range B - A Standard Deviation”
  2. 5.2 The Uniform Distribution · OpenStax, Introductory Statistics 2e · Dec 13, 2023
    “For this problem, the theoretical mean and standard deviation are ... 11.50 seconds and ... 6.64 seconds.”
  3. 4.3 Binomial Distribution · OpenStax, Introductory Statistics 2e · Dec 13, 2023
    “The mean, μ, and variance, σ^2, for the binomial probability distribution are μ = np and σ^2 = npq.”
  4. 4.3 Binomial Distribution · OpenStax, Introductory Statistics 2e · Dec 13, 2023
    “Any experiment that has characteristics two and three and where n = 1 is called a Bernoulli Trial”
  5. 4.6 Poisson Distribution · OpenStax, Introductory Statistics 2e · Dec 13, 2023
    “The Poisson probability distribution gives the probability of a number of events occurring in a fixed interval of time or space if these events happen with a known average rate and independently of the time since the last event.”
  6. 5.3 The Exponential Distribution · OpenStax, Introductory Statistics 2e · Dec 13, 2023
    “The standard deviation, σ, is the same as the mean.”
  7. Introduction to Probability, Chapter 6: Expected Value and Variance · Grinstead and Snell, Dartmouth · Jul 4, 2006
    “In the important case of mutually independent random variables, however, the variance of the sum is the sum of the variances.”
  8. 7.1 The Central Limit Theorem for Sample Means (Averages) · OpenStax, Introductory Statistics 2e · Dec 13, 2023
    “Standard deviation is the square root of variance, so the standard deviation of the sampling distribution is the standard deviation of the original distribution divided by the square root of n.”
  9. 1.3.6.6.1. Normal Distribution · NIST/SEMATECH e-Handbook of Statistical Methods · Nov 19, 2026
    “The central limit theorem basically states that as the sample size (N) becomes large, the following occur: The sampling distribution of the mean becomes approximately normal regardless of the distribution of the original variable.”
  10. 7.1 The Central Limit Theorem for Sample Means (Averages) · OpenStax, Introductory Statistics 2e · Dec 13, 2023
    “The variable n is the number of values that are averaged together, not the number of times the experiment is done.”
  11. Introduction to Probability, Chapter 9: Central Limit Theorem (Historical Remarks) · Grinstead and Snell, Dartmouth · Jul 4, 2006
    “The Central Limit Theorem for Bernoulli trials was first proved by Abraham de Moivre and appeared in his book, The Doctrine of Chances, first published in 1718.”
  12. Seven Rules of Thumb for Web Site Experimenters · Kohavi, Deng, Longbotham and Xu, KDD 2014 · Aug 24, 2014
    “Our experience is that many metrics of interest in online experiments are skewed which may require a higher lower bound before you can assume normality.”
  13. Seven Rules of Thumb for Web Site Experimenters · Kohavi, Deng, Longbotham and Xu, KDD 2014 · Aug 24, 2014
    “At a commerce site, the skewness for purchases/customer was >10 and for revenue/customer >30.”
  14. Seven Rules of Thumb for Web Site Experimenters · Kohavi, Deng, Longbotham and Xu, KDD 2014 · Aug 24, 2014
    “Our rule of thumb for the minimum number of independent and identically distributed observations needed for the mean to have a normal distribution is 355 ... for each variant, where ... is the skewness coefficient”
  15. Seven Rules of Thumb for Web Site Experimenters · Kohavi, Deng, Longbotham and Xu, KDD 2014 · Aug 24, 2014
    “In the table above, we found Revenue/User had a skewness of 18.2 and therefore 114k users were needed.”
  16. Seven Rules of Thumb for Web Site Experimenters · Kohavi, Deng, Longbotham and Xu, KDD 2014 · Aug 24, 2014
    “After we capped Revenue/User to $10 per user per week, we saw skewness drop from 18 to 5.3 and sensitivity (i.e. power) increased.”
  17. 1.3.6.6.3. Cauchy Distribution · NIST/SEMATECH e-Handbook of Statistical Methods · Nov 19, 2026
    “The mean and standard deviation of the Cauchy distribution are undefined. The practical meaning of this is that collecting 1,000 data points gives no more accurate an estimate of the mean and standard deviation than does a single point.”