← All simulations · Pillar 1: Numbers & pictures
Randomness & probability
What it is
Spin a wheel that’s part blue. Any single spin is a surprise — you can’t know it in advance. But spin it a lot, and the share that lands blue creeps closer and closer to the wheel’s true blue fraction. That settling-down is one of the deepest and most useful facts in all of math.
Go deeper: the probability of blue is the fraction of the wheel that’s blue. One spin is random; the average of many spins is predictable. As the number of spins grows, the measured share converges to the true probability — the law of large numbers.
Why care
This is exactly why AI wants lots of examples. From a few, it might learn the wrong lesson by luck; from many, the patterns it measures get closer to the truth. It’s also how polls, A/B tests, and medical trials turn a sample into a trustworthy estimate.
The idea, intuitively
One spin tells you almost nothing — it’s pure luck. Ten spins give a rough hint. A thousand spins give a really good guess at the true odds. The more you spin, the more the luck cancels out and the truth shows through. Watch the blue line jump around at first, then calm down and hug the true-odds line.
Peek at the data first
Each spin is one tiny piece of data: blue or not. Here is what one short run of 12 spins can look like — watch how jumpy the running share is when there are only a few data points. That wobble is exactly why a few examples can fool you.
Try it
Press Spin a few times and watch the blue line lurch. Then press Spin 250 a couple of times and watch it settle near the dashed true-odds line. Change the wheel’s blue share and try again.
Where it shows up
- Sampling & polls. Ask enough people and the result closes in on what the whole group thinks — ask too few and luck takes over.
- Training data. A model’s estimates get steadier and fairer with more examples, for the very same reason.
- Games & simulations. “Monte Carlo” methods estimate hard answers by trying something random many, many times and averaging.
Where it came from
Probability grew out of letters between Blaise Pascal and Pierre de Fermat in 1654, puzzling over a gambling problem. The law of large numbers — the idea you’re watching here — was proved by Jacob Bernoulli and published in 1713 in his book Ars Conjectandi. Their work is the foundation under all of statistics and machine learning.
Try it in code
Spectra’s randomness is seeded so experiments reproduce. Shuffle and take a random sample, then peek at it:
data = load "animals" mixed = shuffle data, seed: 7 few = sample mixed, size: 10 describe_data few
Check your understanding
- Why does the blue line bounce so much in the first few spins?
- After 1000 spins, will the share be exactly the true odds? Why or why not?
- How does this explain why an AI usually does better with more training examples?