Sub topic 3
Drawing With and Without Replacement
This chapter assumes you can multiply fractions, use combinations (written C(n, r) or "n choose r"), and know that a probability lies between 0 and 1.
Drawing With and Without Replacement
With replacement, you put each item back before the next draw, so every draw has the same probabilities. Without replacement, each draw changes the pool. Multiply the sequential probabilities, or count combinations.
from math import comb
from fractions import Fraction
# Bag has 5 red and 3 blue balls; 2 are drawn without replacement.
print(Fraction(comb(5, 2), comb(8, 2))) # 5/14Total Probability and Bayes' Theorem
When a problem has two stages, the law of total probability adds the chances of every route to the outcome. Bayes' theorem then reverses the direction: given the outcome, it finds the chance of an earlier stage.
from fractions import Fraction
via_bag1 = Fraction(1, 2) * Fraction(2, 5)
via_bag2 = Fraction(1, 2) * Fraction(3, 4)
print(via_bag1 / (via_bag1 + via_bag2)) # 8/23Repeated Independent Trials
For n independent trials with success probability p, the chance of exactly k successes is C(n, k) × p^k × (1 − p)^(n−k).
from math import comb
from fractions import Fraction
# Exactly 2 sixes in 4 rolls of a fair die.
print(Fraction(comb(4, 2) * 5**2, 6**4)) # 25/216Expected Value of a Simple Game
The expected value is each outcome multiplied by its probability, summed. For one fair die, it is 7/2.
Choosing a Method and Avoiding Traps
Common traps include forgetting that a draw without replacement changes the pool, and confusing P(A given B) with P(B given A). For "at least one" questions, subtract the probability of none from 1. Use counting for equally likely outcomes, a tree for sequential stages, and the binomial formula for repeated trials.
Exercise
Exercise
A bag has 4 white and 6 black balls. Two are drawn without replacement. What is the probability both are white?
Show answer
C(4,2)/C(10,2) = 6/45 = 2/15.