The unlikely happens too: chance and distributions
Flip virtual coins and watch the distribution appear: why the unlikely, repeated many times, ends up happening. AI course, 1.1.

AI from the First Bit › Level 1 — Uncertainty: the raw material of AI part 1 of 2
An AI model answers with the most probable thing, not with certainties. To understand what that means, you first need one idea: the distribution, the shape that chance takes when it is repeated many times. And the unlikely is not impossible: repeat it enough times and it ends up happening.
Try this first
Open 10 coin flips in the Probability for AI tool. The chart answers one question: if you flip a coin 10 times, how many heads do you get? Each blue bar is a possible outcome, from 0 to 10 heads, and its height is the probability that it comes up. The tallest is the one at 5; the bars at the ends are so small that you can hardly see them.
Click Sample. The tool runs the experiment for real: it flips the 10 coins 8000 times and records how many heads come up each time. The orange bars count how many times each number of heads came up, and they look a lot like the blue ones. (The dashed green line adds up the bars from left to right: it is the cumulative distribution, or CDF; you can remove it by unchecking CDF.)
Hover over the bar at 5 (or open the same coin with that bar already read). Below the chart it says P(X = 5) = 24.6% and how many of your 8000 rounds gave exactly 5 heads: about 1970. Now go to the far right, to 10, where the bar cannot even be seen (already read): P(X = 10) = 0.098%. And even so, in your 8000 rounds it has come up a few times; in the twenty times I clicked Sample to write this article, between 2 and 12.
Finally, open the same coin, loaded, with 80% heads. The shape moves to the right and narrows a little.
What just happened
A single round cannot be predicted. Many rounds can: they have a shape, and that shape is the distribution, the list of possible outcomes with the probability of each one. The one in this experiment, counting how many successes there are in a fixed number of attempts (here, counting heads), is called the binomial. It appears whenever hits are counted: how many of 100 customers buy, how many of a model’s answers are correct, or how many visitors click on each version of an A/B test. An A/B test shows two versions of something, A and B, to two groups of people assigned at random, and counts which one has more successes: more purchases, more clicks, fewer people leaving. Websites and apps use it to decide on a design, but so do software teams when they release a new version: they give it first to a part of the users and compare them with those who stay on the usual one before giving it to everyone. Each group is a binomial, and knowing how much each one varies is what tells you whether the difference is real, as explained in Is my improvement real?.
Two numbers summarize the shape, and the tool shows them on the left:
- The mean, the center: with 10 flips and a 50% chance of heads, 5. In the binomial it is (number of flips times the probability of heads): 10 × 0.5 = 5. With the loaded coin, 10 × 0.8 = 8.
- The standard deviation (STD. in the tool), how far a result usually strays from the center: 1.581 for the fair coin. In the binomial it is . With the loaded one, : the shape is narrower, as you saw.
That the orange bars look like the blue ones is no coincidence: the more times you repeat an experiment, the closer the frequencies get to the probabilities (here, repeating is the number of rounds the tool plays at once, the N next to Sample: 8000 rounds look more like the blue bars than 200 do). This is the law of large numbers, and it was first proved, for experiments with two outcomes like a coin, by Jakob Bernoulli in his Ars Conjectandi, published in 1713 (Law of large numbers, Wikipedia).
An AI model always works with distributions. A language model, when choosing the next word, has in front of it a distribution over all the possible words, and both the good answers and the made-up ones come from how it chooses within it (explained in How it chooses the next word).
The classic mistake
You might think that “unlikely” is almost the same as “impossible”. Getting 10 heads out of 10 is 1 in 1024: on the chart the bar cannot even be seen. But in 8000 attempts, you should expect it to come up about 8000 / 1024 ≈ 8 times.
The calculation is always the same: probability × number of attempts. An AI system that makes a serious mistake in one case out of a thousand looks very reliable in a demo; if millions of people use it every day, that is thousands of serious mistakes every day.
Try it yourself
Open the normal distribution, the “bell curve”, which in AI is used to model noise and errors. Hover past 3 and read the probability that a value comes out above it. The questions below take you through calculating how many of the 8000 samples you expect there, and checking it with Sample.
Test yourself
Open the normal with the cursor at 3. What is the probability that a value comes out above 3?
___%.
It is the reading next to the cursor, “P(X > 3)”.
See the answer
Answer: 0.13 ± 0.01.
Beyond three standard deviations there is very little bell left: a little more than 1 value in every 1000.
Test yourself
Before clicking Sample: of the 8000 samples, how many do you expect to come out above 3?
About ___.
See the answer
Answer: 10 ± 1.
8000 × 0.13% = 10.4. Now click Sample several times and look at the figure below the chart, “in your 8000 samples”: it comes out 5, 8, 11… With so few expected cases, chance weighs a lot. It is the same thing that happens with the coin below when there are few rounds.
And to see the law of large numbers at work, open the fair coin with just 200 rounds and click Sample several times in a row (each time it starts from zero with 200 new rounds). How much do the orange bars change from one time to the next? And with 8000?
Test yourself
What happens to the orange bars when going from 200 rounds to 8000?
- They change just as much from one time to the next: chance is the same.
- They change much less and stick to the probability bars.
- They change more, because there are more rounds that can come out odd.
See the answer
The answer is B.
This is the law of large numbers: the more rounds, the closer the frequencies get to the probabilities. The swing of a frequency goes down with the square root of the number of rounds: with 40 times more rounds, it moves about 6 times less (√40 ≈ 6.3).
Further reading
- On Jarroba, La trampa del agente libre (in Spanish) uses the same idea in reverse: an AI agent that gets 95% of the steps right ends a 20-step task successfully only 35.8% of the time, because the probabilities of each step multiply.
- Binomial distribution, Wikipedia: the formula for each bar and where it comes from.
“The unlikely happens too: chance and distributions” by Ramón Invarato at jarroba.com, licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0. Registered at Safe Creative.

You may also like
Bayes without formulas: why a positive does not mean what it seems
A test that is right 90% of the time and, if you test positive, only a 9% chance of being sick. Bayes by counting people, no formulas. AI course, 1.2.
How a video game character decides: states, trees and scores
Video game AI without learning: state machine, behavior tree, utility as in The Sims, and GOAP. AI course, 0.9.








Leave a comment