Home›Part 1 Probability & Statistics›1.5

Part 1 · Probability & Statistics

1.5 Law of large numbers and the central limit theorem

Why many trials make results stable

9-minute readPrerequisites: 1.3 Probability distributions, 1.4 Expected value and variance▶ Video (about 4 min)

What you will learn

  • Law of large numbers: explain why averages and proportions approach the true value as trials increase
  • Calculate the spread of an average (the standard error, σ/√n) and see why doubling the precision takes four times as many tests
  • Central limit theorem: explain why averages approach a normal distribution, and why this underpins confidence intervals (1.6)

Build intuition

In 1.3 we saw that even a detector with a 90% detection rate gives widely varying results over just 10 tests. So what happens when we run more tests? Let us line up, for each number of tests, the range that contains the observed detection rate about 95% of the time.

True detection rate 90% 10 tests ±19% 100 tests ±6% 1,000 tests ±1.9% 10,000 tests ±0.6% 70% 80% 90% 100% Observed detection rate (range containing about 95% of results)
Even with a true detection rate of 90%, 10 tests could plausibly give anything from 71% to 100% (capped at 100%). Running ten times as many tests shrinks the range only to about one third (1/√10).

The more tests you run, the more tightly the observed detection rate gathers around the true value (90%). This is the law of large numbers, and it is why 1.4 said that six runs are too few.

But the range shrinks slowly. Going from 100 to 10,000 tests — a hundredfold increase — narrows it only from ±6% to ±0.6%, a factor of ten. Precision improves only with the square root of the number of trials.

Check with math

① Law of large numbers: the average approaches the true value

Repeat an independent trial n times under the same conditions, and let \(\bar{X}_n\) be the average of the results \(X_1, \dots, X_n\). As n grows, the average approaches the true mean (expected value) \(\mu\).

$$\bar{X}_n = \frac{1}{n}\sum_{i=1}^{n} X_i \;\longrightarrow\; \mu \qquad (n \to \infty)$$

If you score a successful detection as 1 and a miss as 0, the average is simply the detection rate.

② Standard error: the spread of the average shrinks with √n

If the spread (standard deviation) of a single result is \(\sigma\), the spread of the average of n results is given below. It is called the standard error (SE).

$$\mathrm{SE} = \frac{\sigma}{\sqrt{n}}$$

For success/failure trials \(\sigma = \sqrt{p(1-p)}\), so the standard error of a detection rate is \(\sqrt{p(1-p)/n}\). Testing a detector with a true rate of p = 0.9 a hundred times gives

$$\mathrm{SE} = \sqrt{\frac{0.9 \times 0.1}{100}} = 0.03$$

That is 3%. Applying the rule of thumb from 1.3 (about 95% within ±2σ) means about 95% of observed detection rates fall within 90% ± 6% — exactly the “100 tests” bar in the figure. Because the denominator is \(\sqrt{n}\), halving the standard error takes four times as many trials, and cutting it to a tenth takes a hundred times as many.

③ Central limit theorem: averages approach a normal distribution

Moreover, the average of many trials approaches a normal distribution as n grows, whatever the shape of the original distribution (except for distributions with extremely large spread). This is the central limit theorem.

$$\bar{X}_n \approx N\!\left(\mu,\ \frac{\sigma^2}{n}\right)$$

Let us check with dice. A single die has a “flat” distribution in which 1 to 6 are equally likely, but the average of several dice takes on a different shape.

1 6 1 6 1 6 One die Mean of 2 dice Mean of 5 dice
A single die has a flat distribution, yet the mean of two dice is triangular and the mean of five is already close to a bell shape (normal distribution). Each panel is scaled so that its most likely value has the same height.

Thanks to the central limit theorem, the rule of thumb “about 95% within the mean ± 2SE” works even when the original distribution is not well known. This is the foundation of the confidence interval, the topic of the next lesson.

Connection to automated driving

  • Deciding how many tests to run: to know a detection rate to within ±1% (about 95% of the time) when the true rate is around 90%, \(2\sqrt{0.9 \times 0.1 / n} \le 0.01\) gives about 3,600 tests. Doubling the precision multiplies the number of tests by four.
  • The same holds for simulation: when estimating probabilities by running many trials on a computer (the Monte Carlo method), precision again improves only with the square root of the number of runs. → 5.7 Simulation and XiL
  • For rare events, the number of occurrences is what counts: estimating an event of probability p from n trials gives a relative error of about \(1/\sqrt{np}\), where np is the expected number of occurrences. A 10% relative error requires about 100 occurrences, so an event that happens once in a million trials needs about 100 million trials. → 1.8, 5.8 Searching for unknown hazards
  • The assumption: same conditions, independent trials: the law of large numbers only helps when you add trials from the same distribution. Driving through the same intersection on a sunny afternoon 10,000 times tells you nothing about performance on a rainy night or on other roads. Covering the many conditions of the ODD requires designing what the tests contain. → 4.1 Levels of automation and the ODD, 5.6 Scenario-based testing
  • The normal approximation is good in the middle, poor in the tails: the central limit theorem approximates well near the mean, but it is not suited to estimating the probability of rare, extreme values (the tails) — and the tails are exactly what matter in safety evaluation. → 1.9 Extreme values and heavy tails

Summary

  • The more trials you run, the closer averages and proportions get to the true value (law of large numbers)
  • The spread of an average is the standard error σ/√n; doubling the precision takes four times as many trials
  • The average of many trials approaches a normal distribution (central limit theorem), which underpins confidence intervals. Rare events and distribution tails, however, need other techniques

Quick quiz

Q1. A detector with a true detection rate of 90% is tested 400 times. What are the standard error of the observed rate and the range containing about 95% of results?

The standard error is \(\sqrt{0.9 \times 0.1 / 400} = 0.015\), i.e. 1.5%. The range is 90% ± 3%, roughly 87% to 93%.

Q2. How many times more tests do you need to cut the standard error to one third?

Nine times. The standard error is proportional to \(1/\sqrt{n}\), and \(\sqrt{9} = 3\).

Q3. You want to estimate the probability of an event that occurs once in a million trials, with a relative error of about 10%. Roughly how many trials do you need?

About 100 million. To make the relative error \(1/\sqrt{np}\) equal to 0.1 you need np ≈ 100 — about 100 occurrences — so n ≈ 100 ÷ 0.000001 = 100 million.

Q4. According to the central limit theorem, which approaches a normal distribution? (a) each individual measurement (b) the average of many measurements

(b). The distribution of individual values keeps its original shape (flat, for a die); it is the distribution of the average of many values that approaches a normal distribution.

Further reading