Sub topic 12
From Counting to Probability
This chapter assumes you can compute factorials, permutations, and combinations, and that you can use the complement method (counting "all" minus "the ones you don't want"). It also assumes you are comfortable with fractions. Here you will turn those counts into probabilities and avoid the mistakes that cost points on GRE questions.
The Core Model: Favorable Over Total
When every outcome is equally likely, probability is a ratio of two counts:
P(event) = (number of favorable outcomes) / (number of total outcomes)
All the work is in the two counts. You already have the tools for both. The only new rule is a consistency requirement: the numerator and denominator must be counted in the same way. If the denominator treats outcomes as ordered, so must the numerator. If the denominator treats them as unordered, so must the numerator.
Two facts help you check any answer:
- A probability is always between 0 and 1. If you get 1.4 or 7/5, a count is wrong.
- The favorable outcomes are a subset of the total outcomes. If your numerator is larger than your denominator, you counted the two differently.
A Workflow for Counting Probability
Step 1 is where most errors start. Decide what one outcome looks like before you count anything. Is it a set of three people? An ordered row of five? A pair of dice results?
Worked Example 1: A Committee
A committee of 3 is chosen at random from 6 men and 4 women. What is the probability that it includes at least one woman?
An outcome here is a committee, which is an unordered group, so combinations fit.
- Total: C(10, 3) = 120.
- "At least one woman" is easier through the complement. Committees with no women: C(6, 3) = 20.
- Favorable: 120 − 20 = 100.
- Probability: 100/120 = 5/6.
You can skip the subtraction and work with probabilities directly: P(at least one woman) = 1 − P(no women) = 1 − 20/120 = 5/6.
import math
from fractions import Fraction
total = math.comb(10, 3)
no_women = math.comb(6, 3)
print(Fraction(total - no_women, total)) # 5/6Worked Example 2: Two Methods Must Agree
A bag holds 5 red marbles and 3 blue marbles. You draw 2 marbles without replacement. What is the probability that both are red?
Method A: count unordered pairs.
- Total pairs: C(8, 2) = 28.
- Favorable pairs: C(5, 2) = 10.
- Probability: 10/28 = 5/14.
Method B: multiply step by step.
- The first marble is red with probability 5/8.
- Given that, 4 red remain among 7 marbles, so the second is red with probability 4/7.
- Probability: (5/8)(4/7) = 20/56 = 5/14.
The two methods give the same answer, which is a useful self-check. Method B is the multiplication principle applied to probabilities. "Without replacement" is why the second fraction changes to 4/7. With replacement, it would stay 5/8.
import math
from fractions import Fraction
by_counting = Fraction(math.comb(5, 2), math.comb(8, 2))
by_steps = Fraction(5, 8) * Fraction(4, 7)
print(by_counting, by_steps) # 5/14 5/14Worked Example 3: Ordered Outcomes
Five people are seated in a row at random. What is the probability that two specific people, Ana and Ben, sit together?
Here an outcome is a full seating order, so the total is 5! = 120.
- Glue Ana and Ben into one block. Arrange 4 units: 4! = 24.
- Order the pair inside the block: 2! = 2.
- Favorable: 24 × 2 = 48.
- Probability: 48/120 = 2/5.
The complement is that they are not together: 72/120 = 3/5. Notice 2/5 + 3/5 = 1.
Worked Example 4: Dice and the Equally Likely Trap
Two fair six-sided dice are rolled. What is the probability that the sum is 7?
A tempting model is "the sum can be 2 through 12, which is 11 outcomes, so the answer is 1/11." This is wrong because the sums are not equally likely. A sum of 2 can happen only one way (1 and 1). A sum of 7 can happen six ways.
Use a model where each outcome is equally likely: an ordered pair (first die, second die). There are 6 × 6 = 36 such pairs. The pairs that sum to 7 are (1,6), (2,5), (3,4), (4,3), (5,2), (6,1). That is 6 pairs, so the probability is 6/36 = 1/6.
from itertools import product
from fractions import Fraction
outcomes = list(product(range(1, 7), repeat=2))
sum7 = [o for o in outcomes if sum(o) == 7]
print(len(sum7), len(outcomes), Fraction(len(sum7), len(outcomes))) # 6 36 1/6Treat the two dice as distinguishable, even if they look identical. Pretending that (1,6) and (6,1) are the same outcome breaks the equal-likelihood assumption, because (3,3) would then be only half as likely as (1,6).
Keeping the Numerator and Denominator Consistent
Suppose you pick 2 people at random from a group of 6 to form a pair. You may count unordered pairs or ordered pairs, as long as you pick one.
| Model | Total outcomes | Meaning of one outcome |
|---|---|---|
| Unordered | C(6, 2) = 15 | A set of 2 people |
| Ordered | P(6, 2) = 30 | A first person and a second person |
If exactly one of the 6 people is named Dana, the probability that Dana is picked is:
- Unordered: favorable pairs containing Dana = 5, so 5/15 = 1/3.
- Ordered: favorable ordered pairs with Dana in either position = 5 + 5 = 10, so 10/30 = 1/3.
Both give 1/3. A wrong mix would be 10/15 (ordered numerator, unordered denominator), which is greater than 1/2 and clearly off. Each unordered pair corresponds to exactly P(2, 2) = 2 ordered pairs, so scaling both counts by the same factor leaves the ratio unchanged. That is why either model works, provided you stay in one.
Combining Probabilities: "And" and "Or"
The addition and multiplication principles from the start of this tutorial carry over, with extra conditions.
- "And" for independent events. If one event does not affect the other, multiply. The probability of at least one head and so on in coin flips follows this. For example, two heads in two flips: (1/2)(1/2) = 1/4.
- "And" for dependent events. Multiply the first probability by the second probability given that the first happened, as in Example 2.
- "Or." P(A or B) = P(A) + P(B) − P(A and B). The subtraction is the same overlap correction you used in two-set Venn diagrams. If A and B cannot both happen, then P(A and B) = 0 and you simply add.
For example, a card is drawn from 52. The probability it is a heart or a king is 13/52 + 4/52 − 1/52 = 16/52 = 4/13. The king of hearts is in both groups, so it is counted once and then removed once.
"At Least One" in Probability
Complement counting is even more useful for probabilities. A fair coin is flipped 4 times. What is the probability of at least one head?
- Total outcomes: 2⁴ = 16 equally likely sequences.
- The complement, no heads, is exactly 1 sequence (TTTT).
- P(at least one head) = 1 − 1/16 = 15/16.
Counting every sequence with 1, 2, 3, or 4 heads would work too, but it takes four cases instead of one.
Common Errors
| Error | Why it fails | Fix |
|---|---|---|
| Counting outcomes as sums rather than ordered rolls | Outcomes are not equally likely | Use ordered pairs of distinguishable dice |
| Ordered numerator over unordered denominator | The two counts use different units | Use P for both or C for both |
| Keeping the same fraction after a draw without replacement | The pool shrinks | Reduce both the favorable count and the total |
| Adding probabilities of overlapping events | The overlap is counted twice | Subtract P(A and B) |
| Leaving an unsimplified or impossible answer | Often signals an arithmetic or counting slip | Reduce the fraction and check it lies between 0 and 1 |
Exercises
Exercise
A jar has 4 red and 6 green marbles. Three marbles are drawn at random without replacement. What is the probability that all three are green?
Show answer
Use unordered draws. Total: C(10, 3) = 120. Favorable: C(6, 3) = 20. Probability: 20/120 = 1/6. Check by steps: (6/10)(5/9)(4/8) = 120/720 = 1/6.
Exercise
Five people sit in a row at random. What is the probability that two specific people, Ana and Ben, do NOT sit together?
Show answer
The total is 5! = 120. Seatings with Ana and Ben together: 4! × 2! = 48. Not together: 120 − 48 = 72. Probability: 72/120 = 3/5. Equivalently, 1 − 2/5 = 3/5.
Exercise
A card is drawn at random from a standard 52-card deck. What is the probability that it is a spade or a face card (jack, queen, or king)?
Show answer
Spades: 13. Face cards: 12. Cards that are both (jack, queen, king of spades): 3. Union: 13 + 12 − 3 = 22. Probability: 22/52 = 11/26.