Skip to content
DoingCamp CS

Make it comfy

Lesson style

Quick mode shows the key picture, a summary and the practice. Good for a refresher.

Theme
Font

Both fonts are designed to be easy to read. Some readers with dyslexia prefer Lexend.

Text size
Spacing
Animations

Lesson 2 of 20 · about 15 min

The rules of probability

Roll two dice. What's the chance of at least one six? Most people say 1 in 3, and they're wrong. You'll pick outcomes on a 36-square grid, discover the complement and union rules, and solve the gambling puzzle that started probability theory in 1654.

🧭 What you need first: Chance and frequency , Inclusion–exclusion

The story

You roll two dice. You win if at least one of them shows a six. What’s your chance?

The quick answer goes: “Each die has a 1 in 6 chance, so two dice give 16+16=13\frac{1}{6} + \frac{1}{6} = \frac{1}{3}.” It sounds right. But follow that logic to six dice and you’d get 66=1\frac{6}{6} = 1, a guaranteed six, and you know that’s not true: six dice can all miss.

The mistake is double counting. When both dice show a six, the quick answer counts that win twice. In this lesson you’ll see that happen on a grid, then learn the three rules that fix it. They’re the same counting ideas you met in F06 (complements, inclusion–exclusion), now dressed as probabilities.

Another way: a party guest list

20 friends play guitar and 15 sing. That doesn’t mean 35 people: the 5 who do both were counted twice. 20 + 15 − 5 = 30 musicians. Probabilities overlap the same way.

Play with it

The 36-square grid

Two dice give 36 equally likely outcomes (lesson 1). Here they are: one square per outcome, red die first. Predict each answer before you start tapping.

🎯 1/4: Warm-up: pick every outcome where the sum is 7.

Each square is one way the two dice can land: red die first, blue die second. All 36 are equally likely. Tap squares to pick them (tap again to unpick).

123456
1
2
3
4
5
6

rows: red die · columns: blue die

P(picked) = 0/36

0 of the 36 equally likely outcomes picked.

“At least one six” is 11 squares, not 12: the red-6 row has 6 squares and the blue-6 column has 6, but the corner (6, 6) is in both. So P=1136≈30.6%P = \frac{11}{36} \approx 30.6\%, a bit less than 13\frac{1}{3}. And the opposite event had 25=36−1125 = 36 - 11 squares. That’s no coincidence.

Name it

The real words

  • The three basic rules (called the axioms of probability, written down by Andrey Kolmogorov in 1933). Everything else follows from them:

    1. P(A)≥0P(A) \ge 0 for every event.
    2. P(S)=1P(S) = 1: some outcome always happens.
    3. If AA and BB are disjoint (they can’t both happen), P(A or B)=P(A)+P(B)P(A \text{ or } B) = P(A) + P(B).
  • Complement rule: “not AA” (written AcA^c) happens exactly when AA doesn’t. AA and AcA^c are disjoint and together make all of SS, so rules 2 and 3 give

    P(Ac)=1−P(A)P(A^c) = 1 - P(A)
    • “At least one six” is the complement of “no sixes”: 1−2536=11361 - \frac{25}{36} = \frac{11}{36}. Whenever a question says at least one, try the complement first.
  • Union rule (or), the probability version of inclusion–exclusion (F06 lesson 8):

    P(A∪B)=P(A)+P(B)−P(A∩B)P(A \cup B) = P(A) + P(B) - P(A \cap B)
    • ∪\cup is “or” (either one, or both), ∩\cap is “and” (both).
    • Red six or blue six: 636+636−136=1136\frac{6}{36} + \frac{6}{36} - \frac{1}{36} = \frac{11}{36}. The −136-\frac{1}{36} removes the double-counted (6, 6).
    • Disjoint events have P(A∩B)=0P(A \cap B) = 0, so you just add: sum 2 or sum 12 is 136+136\frac{1}{36} + \frac{1}{36}.
Build it

At least one six

Write p_not(p) (the complement rule), p_or(pa, pb, pboth) (the union rule) and at_least_one_six(n): the exact chance that rolling n dice gives at least one six. Use the complement: the chance that all n dice miss is (5/6) to the power n.

Multiplying 56\frac{5}{6} once per die works because the dice don’t affect each other. Lesson 4 makes that idea (independence) precise.

Challenge

The gambler's puzzle of 1654

A French gambler, the Chevalier de Méré, played two bets. Bet A: roll one die 4 times, win if you get at least one six. Bet B: roll a pair of dice 24 times, win if you get at least one double six. He reasoned they were equally good, yet bet B kept losing him money. He asked Blaise Pascal, who worked it out in letters with Pierre de Fermat. Those letters are often called the birth of probability theory.

Write at_least_once(p, n): the chance that something with probability p (a Fraction) happens at least once in n independent tries. Then bet_a() and bet_b() return the two win chances, and smallest_n(p) returns the fewest tries that give at least a 1/2 chance.

De Méré’s reasoning (“4 tries at 1/6 is like 24 tries at 1/36, since 4×16=24×1364 \times \frac{1}{6} = 24 \times \frac{1}{36}”) is the same double-counting mistake as the story: it adds chances that overlap. The complement rule gets it right.

Remember it

A website has two independent servers. Each is down 10% of the time. The site works if at least one server is up. How often is the site down?

Got it?

Finish the lesson to color it in on your map and collect its concept cards.

Did this lesson click?