12Maths

How chance works

Chance is easy to test and hard to feel. Four experiments in a lab notebook let you roll two dice, flip thousands of coins, fill a room with birthdays and play the three doors puzzle, and see what the maths says and why.

Page one

Lab notebook

Chance is hard to feel and easy to test. In this notebook you run four small experiments on a computer, thousands of times if you like, and watch what chance really does. The computer picks its random numbers with the browser’s own generator.

Chance is the maths of things that are not certain. This page is about the maths. It is not about games for money, and it gives no tips for any.

Experiment one

Two dice

Roll two dice and add them up. There are 36 equally likely ways for the dice to land. Only one of them makes a 2 (1 and 1) and only one makes a 12 (6 and 6). Six of them make a 7. So a 7 comes up 6 times in 36, which is 1 time in 6, and a 2 or a 12 comes up 1 time in 36.

Roll a few times and the bars look ragged. Roll thousands of times and they come close to the exact odds. No sum is ever “due”.

Press Roll to throw two dice.

rolled exact odds

The marks show the exact odds. Without any rolls the bars are the odds: 1 way for a 2, 6 ways for a 7, 1 way for a 12, out of 36.

Experiment two

Flipping coins

A fair coin lands heads half of the time. Flip it 10 times and you may get 7 heads. Flip it 10,000 times and the share of heads gets very close to a half. This is the law of large numbers. It was proved by Jacob Bernoulli and printed in 1713.

The law says the share settles down. It does not say that the coin makes up for a streak. Each flip is a fresh start. Flip a lot of coins, and then look at how often the flip after a run of five of the same matches the run.

100%50%0%1101001,00010,000number of flips
Flips
0
Heads
-
Heads minus tails
-
Longest run
-

Flip the coin. Watch the share of heads wander at first and settle later.

Experiment three

The shared birthday

How many people must be in a room before two of them probably share a birthday? Most people guess about 180, half of 365. The answer is 23. With 23 people the chance of a match is about 50.7 per cent. With 70 people it is about 99.9 per cent.

The reason is pairs. A room of 23 holds 253 pairs of people, and each pair has a small chance to match. Fill a room and see, then slide the number of people and read the odds.

100%50%0%120406080people in the room

With 23 people there are 253 pairs, and the chance that at least one pair shares a birthday is about 50.7%.

Experiment four

Three doors

A prize is behind one of three doors, and there is nothing behind the other two. You pick a door. A host who knows where the prize is opens one of the other two doors, and always shows you an empty one. Then the host asks whether you want to stay or switch to the other closed door.

Most people think it makes no difference. It does. Switching wins 2 times in 3 and staying wins 1 time in 3. Play it by hand a few times. Then let the computer play a thousand games each way.

Scores
PlanGamesWonShare
Stay00-
Switch00-

This game needs a script. A prize is behind one of three doors. You pick one. The host, who knows where it is, opens an empty door. Switching to the last closed door wins 2 times in 3.

Key takeaways

  1. With two dice there are 36 equally likely outcomes. A 7 can happen 6 ways and a 2 or a 12 only 1 way. A sum is never “due”.
  2. The share of heads in many coin flips gets close to a half (the law of large numbers), but the coin does not make up for a streak.
  3. The flip after a run of the same side is just as likely to break the run as to carry it on. The gambler’s fallacy is the belief that it is not.
  4. In a room of 23 people there is about a 50.7 per cent chance that two share a birthday, because there are 253 pairs.
  5. In the three doors puzzle, switching wins 2 times in 3, as long as the host always opens an empty door.
  6. Computer simulations are a way to test an answer. Whether the maths is right is a different question that has to be argued.

Sources

Most of these sites could not be opened while this page was written, so the facts were checked through search results that quote them. The 36 ways for two dice and the odds of 6 in 36 and 1 in 36, the 23 people and 50.7 per cent (and 99.9 per cent for 70), the 2 in 3 of the three doors puzzle with its assumptions, and the law of large numbers in 1713 each appeared in at least two places. The experiments are simulations made for this page. They use the random numbers of your browser, so a run will differ from the next one. This page is about the maths of chance and gives no advice about gambling.