The Average Is the Answer
Last timeMaking a Random Draw
The average of many draws settles on the quantity wanted. This lesson says why it does, what has to be true for it to, and what the settling looks like while it happens.
The previous two lessons set up a loop: draw, compute, average. This one
answers the question that loop raises, which is why the average should be the
number that was wanted.
- the estimate formed from n draws, which is itself random
- the true quantity, fixed and unknown
- the spread of a single draw, which the problem fixes and the method cannot change
- the number of draws taken
- the typical distance of a random quantity from its own average
| step | draws so far | estimate | typical error at this point | comment |
|---|---|---|---|---|
| 1 | 10 | 0.2900 | 0.158 | swinging, and the first digit is not yet reliable |
| 2 | 100 | 0.3510 | 0.050 | in the right region |
| 3 | 1 000 | 0.3367 | 0.016 | two digits look stable |
| 4 | 10 000 | 0.3340 | 0.005 | third digit settling |
| 5 | 100 000 | 0.33318 | 0.0016 | four digits, at ten times the cost of the line above |
| 6 | the true value | 0.33333 | 0 | an exact third |
When it fails
Two conditions underlie all of this. The draws must be independent, and the
quantity must have a genuine average.
The second is easier to show than to describe. Some quantities have tails so
heavy that occasional enormous values dominate everything drawn before them,
and the running average jumps each time one arrives rather than settling.
Insurance losses, file sizes, city populations and wealth all behave this way
to some degree.
import numpy as np
rng = np.random.default_rng(3)
x = rng.random(100_000)
for n in (10, 100, 1_000, 10_000, 100_000):
print(n, round(float(np.mean(x[:n] ** 2)), 5)) # settles on 0.33333
heavy = 1.0 / rng.random(100_000) # a tail with no finite average
for n in (10, 100, 1_000, 10_000, 100_000):
print(n, round(float(np.mean(heavy[:n])), 2)) # jumps, never settles
print(float(np.max(heavy))) # one draw larger than most sumsIndependence fails more quietly. Draws that share a source of randomness, a
simulation that carries state from one run into the next, or a generator with
hidden structure all produce draws that lean the same way, and the average of
those converges to something, just not to the quantity wanted. The final
lesson of the course is about catching that.
The lesson stops here
1 more paragraph to go
You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.
The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.
See the planThe contentsThis is the reading half
Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.
The contents