The Monty Hall problem
One door hides a car and the other two hide goats. You pick a door. The host, who knows where the car is, opens a different door to show a goat, then lets you stay with your pick or switch to the last closed door.
Pick a door.
Keys: 1 2 3 choose a door, N starts a new game.
| Choice | Played | Won | Win rate |
|---|---|---|---|
| Stayed | 0 | 0 | – |
| Switched | 0 | 0 | – |
Simulate many games
Both choices are played on the same games, so in every game exactly one of them wins.
Switching won – No games yet
Staying won – No games yet
Why switching wins
Your first pick is the car one time in three. The host knows where the car is and can always open a goat door, so opening one tells you nothing new about your own door. It still wins one time in three, which leaves two in three for the door he kept shut.
Switching loses only when your first pick was the car. That happens 1/3 of the time, so switching wins 2/3 of the time.
The effect is easier to see with more doors. With 100 doors, you pick one and the host opens 98 goat doors, leaving one other door closed. Switching wins unless your first guess was right: 99 times in 100.
These numbers depend on the host's rules. He always opens a door you did not pick, always reveals a goat, and always offers the switch. A host who offered a switch only when your first pick was the car would make switching lose every time.
The birthday problem
How many people does a room need before two of them probably share a birthday?
50.7%
chance that at least two people share a birthday
- Pairs of people
- 253
- Chance someone shares your birthday
- 5.9%
Fill rooms at random
The chance of no match
It is easier to work out the chance that everyone has a different birthday. The second person's birthday differs from the first person's with probability 364/365, the third person's differs from both with probability 363/365, and so on for each new person. Multiply those together and subtract the result from 1.
The surprise comes from pairs. Twenty-three people make 253 pairs, and every pair is a chance for a match. A match with one particular birthday, such as yours, is much rarer: it takes 253 other people before that chance passes 50%.
The model assumes 365 equally likely birthdays and leaves out February 29. Real birthdays are not spread perfectly evenly, and any unevenness makes a match slightly more likely.
The Galton board
Balls fall through rows of pins. At every pin a ball bounces left or right, and the bins at the bottom collect where it lands.
Balls landed 0
Average right bounces – exact 6.00
Counts by bin
| Right bounces | Balls | Share | Exact probability |
|---|
Pascal's triangle in the pins
To land in bin k of a board with n rows, a ball has to bounce right exactly k times out of n. The number of paths that do that is the binomial coefficient, entry k of row n in Pascal's triangle. On a fair board every path has probability 1/2n, and in general:
P(bin k) =n!k! (n − k)! pk (1 − p)n − k
Tilt the pins with the slider and the pile moves to one side but keeps the same binomial shape. Add rows and its outline approaches the smooth bell of the normal distribution, the same shape the dice sums grow into below.
Francis Galton designed the board for a lecture in 1874. It is also called a quincunx or a bean machine.
The law of large numbers
Flip a fair coin many times. The share of heads swings widely at first, then settles closer and closer to one half.
Flips 0
Heads 0
Share of heads –
Heads minus tails 0
That is 200,000 flips. Reset to flip again.
Share of heads
Heads minus tails
What follows a streak
: no flips yet.
A coin has no memory
After five heads in a row, it can feel as if tails is more likely next. It is not. Each flip is independent of the ones before it, so the chance of heads stays 1/2 whatever just happened. Your own flips show it: after a streak of heads, the next flip is still heads about half the time.
Then why does the share of heads settle? There is no pull toward balance. The gap between heads and tails usually grows as you keep flipping, roughly with the square root of the number of flips. The number of flips grows much faster, so the gap divided by the flips shrinks, and the share of heads approaches 1/2. That is the law of large numbers.
Sums of dice
A single die gives each face the same chance. Add dice together and the middle sums become more common, because more combinations produce them.
Roll to see a sum.
Rolls 0
Average sum – exact 7
Every sum, exact and rolled
| Sum | Ways | Probability | Percent | Your rolls |
|---|
Counting combinations
Two dice have 6 × 6 = 36 equally likely outcomes. A sum of 7 comes from six of them, so its probability is 6/36 = 1/6. A sum of 2 needs two ones: 1/36.
More dice are counted the same way. To reach a sum s with k dice, the first k − 1 dice must reach a sum from s − 6 to s − 1, and the last die adds the rest, from 1 to 6. Add the counts for those six sums. As dice are added the shape rounds into a bell. The average sum of k dice is 3.5k, while the spread widens only with the square root of k.
Random walks
A walker takes steps of one unit, each in a random direction and independent of the last. How far away does it get?
On a line
Each step goes left or right with equal chance.
Typical distance – root mean square
Square root of steps –
First walker ended at –
On a grid
Each step goes north, south, east or west with equal chance.
Distance from start –
Square root of steps –
Times back at the start –
Points visited –
The square root rule
Random steps partly cancel one another. After n steps the average squared distance from the start is exactly n, so the root mean square distance is √n. For 10,000 steps that is 100 units, far less than 10,000.
In 1921 George Pólya proved that a walker on a line or on a flat grid is certain to come back to its starting point eventually, however long that takes. On a three-dimensional grid the chance of ever returning drops to about 34%.
Seed
Each visit starts from a fresh random seed. Set your own, and the same clicks in the same order give the same doors, rooms, balls, flips, rolls and walks.