The law of large numbers
Averages settle down as you add draws, but no draw ever makes up for an earlier one. See when the law works, and the one case where it fails.
What runs in CodeSplash
- Monte Carlo simulation of a scenario model Verified in Python and R
You will be able to
- State what the law of large numbers promises
- Tell it apart from the gambler's fallacy
- Say why simulations get more accurate as draws are added, and how fast
Read first
Averages settle down
ReadThe law of large numbersLaw of large numbersThe average of many independent draws gets close to the expected value, if one exists. says that the average of independent draws gets closer and closer to the expected value as you add draws, if that expected value exists.
It's why casinos, insurers and simulations can plan on long-run averages, even though single outcomes are unpredictable.
After a run of heads
PredictPredict first
A fair coin has landed heads 8 times in a row. What is the chance of heads on the next flip?
Reveal
Still a half. The coin has no memory, and nothing evens out. The average settles because later flips dilute the early run, and no flip corrects it. That gap between the law and the belief is the gambler's fallacy.
Watch the averages
ExploreEach line is a running average. Guess how far off it will be, then raise Draws n and Running averages. Then switch Population to Cauchy, or use the break-it setting. What happens to the lines?
AExplorable · The law of large numbers
Does the average of more and more draws settle on the true mean?
After all n draws, how far from the true mean will a running average typically be?
Population
Commit your prediction above to see the result
Make your prediction to see the result.
When there's nothing to settle on
ReadThe law needs a finite expected value. A Cauchy distribution has so much weight in its tails that a single huge draw can move the average at any point, however many draws came before.
Real data with very heavy tails, such as incomes or claims, can behave a bit like this: the running average lurches when an extreme value arrives. The median is often steadier.
How simulations get accurate
ExploreA simulation's accuracy follows the same law. Its error is about .
One stocking simulation has a standard deviation of 1,653 over 5,000 scenarios, so its average is good to about . Try this: run the code and change the number of draws.
import numpy as np
rng = np.random.default_rng(1)
for n in [100, 10_000, 1_000_000]:
draws = rng.exponential(scale=1.0, size=n)
print(n, round(draws.mean(), 4))set.seed(1)
for (n in c(100, 10000, 1000000)) {
draws <- rexp(n, rate = 1)
cat(n, round(mean(draws), 4), "\n")
}Check your reading
CheckpointCheck yourself
What does the law of large numbers promise?
Show the answer
Answer: b
It concerns averages, and only in the long run. It says nothing about the next draw, and it doesn't protect a biased sampling method.
Check yourself
After 1,000 flips of a fair coin you have 520 heads. What do you expect after 1,000 more flips?
Show the answer
Answer: b
You expect 500 more heads, for 1,020 in all. The share falls from 52% to 51%, even though the raw excess stays at 20.
Check yourself
You want a simulation's error to be 10 times smaller. How many times as many draws do you need?
Show the answer
Answer: 100
The error falls with , so ten times smaller takes times the draws.
Try it in the app
In the appAny Monte Carlo result in CodeSplash depends on this law: a permutation p-value, a bootstrap interval or a scenario simulation. Raise the replications when the result needs to be more stable. Try it with Monte Carlo permutations in this test.
Recap
Recap- Averages of independent draws settle on the expected value, if one exists.
- They settle by dilution. Nothing evens out, so the next flip is still a coin flip.
- Simulation error falls with : ten times better takes a hundred times the draws.
Concepts in this lesson