Mathematics · probability theory
Probability chance has its laws
Nobody can predict a single roll of a die. But a thousand rolls fall into a shape you can calculate to a fraction of a percent. Roll dice, drop balls through a Galton board, play against Monty Hall, and find out why a positive test doesn't always mean “you're sick” — and how a chart can lie even when every number on it is true.
Law of large numbers
What we throw
The gambler's fallacy
After five heads in a row, “tails is due”? A coin has no memory. Let's check, over a huge number of tosses, what comes up right after a run of heads.
Can you fake randomness?
Type 50 “random” tosses off the top of your head: the letter H is heads, T is tails (or click the buttons). Then compare your sequence with a truly random one. People usually switch too often and avoid long runs — yet in 50 tosses a run of 5 or more identical results happens about 4 times out of 5.
The red frame marks the longest run. A truly random sequence of 50 tosses has on average about 24–25 switches, and its longest run is usually 5–7 tosses.
Board
Drop
Overlays
Bin k = number of bounces to the right. The mean is np, and the standard deviation is √np(1 − p).
Central limit theorem
Take anything random — a die, a number from an interval, a waiting time — and add up several such results. The sum looks more and more like a bell.
Bells and non-bells in the world
The Monty Hall problem
Behind one door is a car; behind the others, goats. You pick a door, and the host — who knows where the car is — opens another door with a goat. Do you stay or switch?
| Strategy | games | wins | win % |
|---|---|---|---|
| stay | 0 | 0 | — |
| switch | 0 | 0 | — |
The simulation doesn't count toward the challenge — you have to win that yourself.
The birthday paradox
How many people must be in a room for two of them to share a birthday with a chance greater than 50%? Intuition says about 180. Move the slider.
Linda and the conjunction fallacy
“Linda is 31 years old, outspoken, and very bright. She majored in philosophy, was deeply concerned with issues of social justice, and took part in demonstrations.” Which is more probable?
Pick an answer. This is the famous question by Amos Tversky and Daniel Kahneman (1983).
Count with figures, not percentages
The same reasoning elsewhere
Spam filter: the word “winner” shows up far more often in spam than in ordinary email, but whether a message is spam also depends on how much spam you get in the first place — a Bayesian filter multiplies both factors.
Weather forecast: “a 70% chance of rain” means that on days with such a forecast it actually rains roughly 7 times out of 10 — that, too, is a conditional frequency, not a promise.
Sensitivity is P(+ | sick), and specificity is P(− | healthy). But doctors and patients care about the reverse question: P(sick | +). Mixing up these two directions even has a name: the prosecutor's fallacy.
The numbers in the examples are textbook ones and don't refer to any specific disease or test.
Mean, median, mode
Commute times to school in one class (in minutes). Drag the dots and see which measure moves.
How to lie with a chart
Correlation is not causation
Poll: 10 or 1000 people?
In reality 40% of people support something. We ask random people and record the result of each poll as a dot.
Lotto 6/49: is it worth it?
In Lotto, Poland's national lottery, you pick 6 numbers out of 49. There are C(49, 6) = 13,983,816 possible sets of 6 numbers, so the chance of hitting all six with one ticket is 1 in almost 14 million.
| Matches | ways | odds 1 in | prize [zł] |
|---|
Prizes for 4, 5 and 6 matches change with every draw — the table shows sample amounts, and you can edit them. With a big rollover more people play, so the jackpot gets shared more often, and in Poland winnings above 2,280 zł (about $600) are taxed at 10%. For scale: 1 zł is roughly 25 US cents.
Roulette: the house always wins
European roulette has 37 pockets: 18 red, 18 black and a green zero. A 1 zł bet on red wins 1 zł with probability 18/37 and loses with probability 19/37:
Relative and absolute risk
A short history of chance
- 1654In their letters, Blaise Pascal and Pierre de Fermat solve the “problem of points”: how to fairly split the stakes of an interrupted game. This is usually counted as the birth of probability theory.
- 1713Jakob Bernoulli — in his Ars Conjectandi, published after his death — proves the first version of the law of large numbers: frequency approaches probability.
- 1733Abraham de Moivre shows that the number of heads in many coin tosses follows a bell curve.
- 1763An essay by Thomas Bayes appears, published after his death by Richard Price: how to update beliefs in light of data.
- 1809–1812Carl Friedrich Gauss describes the distribution of measurement errors, and Pierre-Simon Laplace develops the theorem that makes the bell appear wherever many small causes add up.
- 1906Marian Smoluchowski (independently of Einstein) explains Brownian motion: a grain of pollen jiggles because it collides at random with molecules.
- 1923Hugo Steinhaus of Lwów (now Lviv) describes an infinite sequence of coin tosses in the language of measure theory — one of the steps toward modern probability theory.
- 1933Andrey Kolmogorov lays down the axioms of probability on which today's theory rests.
- 1946Stanisław Ulam, a mathematician from Lwów working at Los Alamos, comes up with the Monte Carlo method while playing solitaire; he develops it with John von Neumann, and Nicholas Metropolis suggests the name.
MathematicsHow to calculate chance
Probability and frequency
When all outcomes of a trial (a throw, a draw) are equally likely, the probability of an event A is the ratio of the number of favorable outcomes to the number of all outcomes:
The law of large numbers says that in a long series of independent trials the frequency nA/n approaches P(A). Typical fluctuations shrink like 1/√n: to make the error ten times smaller, you need a hundred times more trials. The law does not work by “evening out” — a coin doesn't remember previous tosses; an excess of heads simply gets diluted in an ever larger number of tosses.
Independence and conditional probability
From this follows Bayes' theorem — a recipe for reversing a condition:
For a disease that affects 1 in 1000 people and a test with 99% sensitivity and specificity, the answer is only about 9%: false alarms among the 999 healthy people outnumber the truly sick ten to one. Psychologist Gerd Gigerenzer showed that people reason about this much better when, instead of percentages, they get natural frequencies: “10 sick out of 10,000, the test catches almost all of them; 100 false positives.”
Distribution, mean and deviation
A distribution tells you how often each result occurs. The two basic numbers are the mean (the center of mass) and the standard deviation (the typical distance from the mean):
The median is the middle value once the data are sorted from smallest to largest — half the results are smaller, half larger. It is robust to outliers; the mean is not. The mode is the most common result. The expected value E[X] = Σ xi pi is the average you can expect over a very long series — for a casino, it is simply its profit per bet.
The binomial distribution and the Gaussian curve
A ball on a Galton board turns right in each of the n rows with probability p, independently of earlier bounces. The number of right turns k has a binomial distribution:
For large n it resembles the normal distribution (the Gaussian curve). By the central limit theorem, the sum of many independent terms with finite variance behaves the same way — which is why the bell shows up in measurement errors and, approximately, in people's heights. About 68% of results lie within μ ± σ, about 95% within μ ± 2σ, and about 99.7% within μ ± 3σ.
Correlation vs. causation, samples and error
The correlation coefficient r (from −1 to 1) measures how closely the points line up along a straight line. A high r doesn't tell you what causes what: ice cream sales and drownings rise together because both are driven by summer. In a poll with a sample of n random people, the error of the result (at about 95% confidence) is roughly ±1/√n: for 1000 people, about ±3 percentage points — as long as the sample is truly random.
Simplifications on this page
The balls on the Galton board are not physically simulated: each bounce is a separate random draw with probability p, and the motion is just animation. In the Monty Hall game the host always opens a door with a goat and always offers a switch. The birthday paradox assumes 365 equally likely days (no February 29). The second test in Bayes mode is independent of the first — real repeated tests often aren't. The data on height, income, cities, ice cream and polls are generated for illustration; they only roughly match the shape of real data.
Did you know…?
- It takes only 23 people for the chance that two of them share a birthday to exceed 50% (exactly 50.7%). With 70 people it's already over 99.9%.
- A deck of 52 cards can be arranged in 52! ≈ 8 · 10⁶⁷ ways. So a well-shuffled deck is almost certainly in an order that no one has ever seen before.
- Stanisław Ulam, a mathematician from Lwów, came up with the Monte Carlo method while playing solitaire as he recovered from an illness, wondering how often a game could be won. Instead of calculating, it was easier to… play it many times.
Challenges
- Most common sum of two diceRoll two dice at least 10,000 times and click the bar of the most common sum.not completed
- A bell curve from 500 ballsCollect at least 500 balls in the bins of the Galton board.not completed
- 20 wins by switchingWin 20 Monty Hall games (3 doors) by switching doors.not completed
- The birthday paradox thresholdFind the smallest number of people for which a shared birthday is more likely than not.not completed
- A test you can trustSet the prevalence, sensitivity and specificity so that a single positive result means disease in more than 90% of cases.not completed
- Mean versus medianShow data in which the mean exceeds the median by more than half (e.g., median 10, mean over 15).not completed
Challenges check themselves. Progress is saved in this browser.
See also
Genetic drift, radioactive decay, the speeds of gas molecules and measurement in quantum mechanics — probability rules them all.