Probability, lesson 2
Probability is counting
Favourable outcomes over possible ones, and when that rule breaks.
The last lesson counted how many ways something can happen. This one turns those counts into chances, and shows the one condition that makes that work. You need the multiplication rule and C(n, k) from the last lesson.
By the end, you can:
Part 1. A chance is a share of outcomes
Find a chance by counting equally likely outcomes.
Roll two dice, one red and one blue. The red die can land 6 ways, and for each of those the blue die can land 6 ways: 6 × 6 = 36, the multiplication rule from the last lesson. Each of the 36 is one way the roll can come out, such as red 2 and blue 5.
Example 1.1
A total of 7
Roll a red die and a blue die. What's the chance the two add up to 7?
- Count every outcome6 × 6 = 36
Draw them as a grid, red die down the side and blue across the top. Each square is one outcome.
- Count the outcomes you want6
1 + 6, 2 + 5, 3 + 4, 4 + 3, 5 + 2 and 6 + 1, red die first.
- Divide6 / 36 = 1/6
Every square is as likely as any other, so the share of squares is the chance.
Answer1/6, about 17%.
Why does dividing give the chance? Fair dice have no favourite face, so no square is more likely than another. The 36 squares share all the chance between them, 1/36 each, and the six 7s get 6/36.
A chance of 1/6 promises nothing about a single roll. It describes the long run: roll the pair 600 times and about 100 rolls total 7. You'll rarely get exactly 100, but the share of 7s settles toward 1/6 the longer you keep rolling.
Sample space and event
The sample space is every outcome that can happen: the 36 squares. An event is a set of outcomes you care about, such as "the total is 7". If every outcome is equally likely, P(A), read "the probability of A", is A's share of them:
P(A) = (outcomes in A) / (all outcomes)
The rule turns the last lesson's counts into chances. A well-shuffled deck makes every five-card hand equally likely, so a full house has chance 3,744 / 2,598,960, about 0.14%. With cards, the hard part is always the count.
Your turn
Roll a red die and a blue die. What's the chance the total is 9?
Part 2. Outcomes that aren't equally likely
Spot outcomes that aren't equally likely, and weigh them.
Guess first
Flip two fair coins. What's the chance of one head and one tail?
If you said 1/3, you treated "two heads", "two tails" and "one of each" as equally likely. "One of each" happens two ways, so it's twice as likely as either other. Dice that look alike set the same trap.
Example 2.1
Doubles with dice that look alike
Roll two identical white dice. You can't tell 2 and 5 from 5 and 2, so you see 21 outcomes: 6 doubles and 15 mixed pairs. What's the chance of a double?
- Tell the dice apart6 × 6 = 36
Mark one die in your head. The dice land the same way whether you can tell them apart or not.
- Count the squares of each outcome6 × 1 + 15 × 2 = 36
A double like 3 and 3 is one square. A mixed pair like 2 and 5 is two squares, since either die can show the 2.
- Divide6 / 36 = 1/6
Not 6/21, about 29%. The 21 outcomes aren't equally likely, so they can't go on the bottom.
Answer1/6, about 17%.
Not being able to tell the dice apart is about you, not the dice. They still land like a red die and a blue one. So count in outcomes that are equally likely, the squares, and group them afterwards.
Equally likely
Outcomes are equally likely when none is favoured over another, like the 36 squares of two fair dice. Only then is a chance a count over a count. Otherwise, add up the chance of each outcome in the event:
P(A) = sum of the chances of the outcomes in A
Some outcomes really aren't equally likely. Say a die is loaded so a six comes up 1/4 of the time and each other face 3/20. An even number then has chance 3/20 + 3/20 + 1/4 = 0.55, not 0.5. Counting is the special case where every outcome has the same weight.
Your turn
Toss three identical coins. You only see how many heads there are: 0, 1, 2 or 3. What's the chance of exactly 2 heads?
Part 3. Counting the opposite
Find an "at least one" chance by counting the opposite.
Roll one die four times. Is at least one six more likely than not? Counting it head-on means adding up the sequences with exactly one, two, three and four sixes. The other side takes one step: count the sequences with no six at all.
Example 3.1
At least one six in four rolls
Roll a die four times. What's the chance of at least one six?
- Count every outcome6 × 6 × 6 × 6 = 1,296
Four rolls with 6 faces each, every sequence equally likely.
- Count the outcomes with no six5 × 5 × 5 × 5 = 625
Each roll has 5 faces that aren't a six.
- Take them away1,296 − 625 = 671
Every other sequence has at least one six.
- Divide671 / 1,296 ≈ 0.518
Just better than even.
AnswerAbout 51.8%, so yes, just.
Why does it work? Every sequence either has a six or it doesn't, never both. So the two groups split all 1,296 sequences between them, and their chances add up to 1.
Complement
The complement of an event is everything else: "no six" is the complement of "at least one six". P(not A), read "the chance A doesn't happen", is one minus the chance it does:
P(not A) = 1 − P(A)
The tempting shortcut adds: each roll has a 1/6 chance of a six, so four rolls give 4/6. By that sum, seven rolls would give 7/6, more than certain. Adding chances only works for events that can't happen together. A six on the first roll and a six on the second can, so the sum counts some sequences twice.
This bet is old. In a letter of 29 July 1654, Blaise Pascal told Pierre de Fermat that the Chevalier de Méré knew four rolls for a six won 671 to 625. De Méré expected 24 rolls of two dice for a double six to win too, because 24 is to 36 as 4 is to 6.
Your turn
Now roll two dice 24 times. Is at least one double six more likely than not?
Where you'll meet it
Dice and card chances come up often in quant trading interviews, usually with fresh numbers: a total of 9 with two dice, at least one ace in three cards, at least one head in ten flips. Two habits get most of them right. Count outcomes that are equally likely, squares and not totals. Count "at least one" through its complement.
Historical simulation, a standard way to estimate a portfolio's risk, is counting. Replay each of the last 500 days of market moves on today's positions, and count the days that would have lost more than 1 million dollars. If 5 would have, the estimated chance of such a loss tomorrow is 5 / 500 = 1%. A kind of day the window never saw gets a chance of zero.
from fractions import Fraction
from itertools import product
squares = list(product(range(1, 7), repeat=2)) # the 36 ways two dice land
sevens = [s for s in squares if sum(s) == 7]
print(Fraction(len(sevens), len(squares))) # 1/6
look_alike = {tuple(sorted(s)) for s in squares}
doubles = [s for s in squares if s[0] == s[1]]
print(len(look_alike), Fraction(len(doubles), 36)) # 21 1/6
no_six = Fraction(5, 6) ** 4
print(1 - no_six, round(float(1 - no_six), 3)) # 671/1296 0.518
print(round(1 - (35 / 36) ** 24, 3)) # 0.491Python prints the 21 look-alike outcomes without complaint. It can list outcomes for you, but it can't tell you which ones are equally likely. That part is yours.
Check yourself
Four questions from across the lesson. Try each one before you look back.
1
Someone says: "There are 11 totals, so a 12 has chance 1/11." What's the real chance?
2
Deal three cards from a shuffled deck. What's the chance at least one is an ace?
3
A team of 2 is picked at random from 4 analysts and 6 engineers. What's the chance both are analysts?
4
A die is loaded so a 6 comes up half the time and each other face 1/10 of the time. What's the chance of a 5 or a 6?
What to remember
1A chance is a share of outcomes
When every outcome is equally likely, a chance is a count over a count: 6 of the 36 squares total 7, so the chance is 1/6.
2Outcomes that aren't equally likely
Count in outcomes that are equally likely. Two dice that look alike still land 36 ways, so a double is 6/36, not 6/21.
2Outcomes that aren't equally likely
When outcomes aren't equally likely, add their chances: on the loaded die, an even number is 3/20 + 3/20 + 1/4 = 0.55.
3Counting the opposite
For "at least one", count the opposite: at least one six in four rolls is 1 − (5/6)⁴ = 671/1,296, about 51.8%.
3Counting the opposite
Add chances only for events that can't happen together. Four rolls at 1/6 each don't make 4/6, because the sum counts some sequences twice.
Probability overviewSpotted a mistake? Tell us.