Quick summary
Summarize this blog with AI
Probability questions become easier when you define the sample space and identify which events depend on one another. This reference uses four worked examples with exact arithmetic. For longer interview cases involving feeds, reviewers, and base rates, use the seven worked probability questions.
1. Combine overlapping events correctly
Suppose P(A) = 0.4, P(B) = 0.3, and P(A ∩ B) = 0.1. The probability of at least one event is P(A ∪ B) = P(A) + P(B) − P(A ∩ B) = 0.6. Adding 0.4 and 0.3 alone double-counts the overlap.
The probability of A given B is 0.1/0.3 = 1/3. This conditional probability is defined because P(B) is positive. The events are not independent: 0.4 × 0.3 = 0.12 differs from the actual intersection 0.1. They are also not mutually exclusive, because their intersection is nonzero.
from fractions import Fraction
pa, pb, overlap = Fraction(2, 5), Fraction(3, 10), Fraction(1, 10)
print("union:", pa + pb - overlap)
print("A given B:", overlap / pb)
print("independent:", overlap == pa * pb)
The output is 3/5, 1/3, and False. In the elementary event formula, conditioning on a zero-probability event is undefined. Also check that supplied probabilities are mutually consistent; not every arbitrary overlap is possible.
2. Distinguish sampling with and without replacement
A bag contains five red and three blue balls. Draw two without replacement. The probability of one of each is (5/8)(3/7) + (3/8)(5/7) = 15/28, approximately 0.5357. The second draw depends on the first because the bag’s composition changes.
The same result follows by counting unordered pairs: choose one of five red and one of three blue, then divide by the number of pairs from eight balls. With replacement, the probability becomes 2(5/8)(3/8) = 15/32, approximately 0.4688.
from math import comb
from fractions import Fraction
without_replacement = Fraction(comb(5, 1) * comb(3, 1), comb(8, 2))
with_replacement = 2 * Fraction(5, 8) * Fraction(3, 8)
print(without_replacement, float(without_replacement))
print(with_replacement, float(with_replacement))
State whether order matters in the counting argument. Counting unordered favorable outcomes but ordered total outcomes would produce the wrong denominator.
3. Specify what a geometric variable counts
Independent trials each succeed with probability 0.2. If T counts trials through the first success, then P(T = k) = (1−p)ᵏ⁻¹p for k = 1, 2, …, and E[T] = 1/p = 5. The probability of success within the first three trials is 1 − 0.8³ = 0.488.
If a variable instead counts failures before the first success, its support starts at zero and its mean is (1−p)/p = 4. These are different conventions for the same process. The model requires constant success probability and independent trials. With p = 0, success never occurs and the waiting-time expectation is not finite.
4. Use indicator variables for expected distinct values
Draw three times independently with replacement from four equally likely labels. Let Iⱼ indicate whether label j appears at least once. Each label is absent with probability (3/4)³, so E[Iⱼ] = 1 − (3/4)³. The expected number of distinct labels is 4[1 − (3/4)³] = 37/16 = 2.3125.
The indicators are dependent, but expectation still adds. Independence is needed for the absence probability across draws, not for adding the four indicator expectations. An expected value need not be an achievable integer outcome in one trial.
from fractions import Fraction
from itertools import product
outcomes = list(product(range(4), repeat=3))
enumerated = Fraction(sum(len(set(draws)) for draws in outcomes), len(outcomes))
formula = 4 * (1 - Fraction(3, 4)**3)
assert enumerated == formula
print(formula, float(formula))
The enumeration checks all 64 equally likely ordered outcomes. This is practical for a tiny fixture; it is not an efficient general method for a large sample space.
Choose a model from its assumptions
| Model | Typical quantity | Assumption to check |
|---|---|---|
| Bernoulli | One binary outcome | A specified success probability |
| Binomial | Success count in a fixed number of trials | Independent trials with the same success probability |
| Hypergeometric | Success count in a finite-population sample | Uniform sampling without replacement |
| Geometric | Waiting until first success | Independent trials, constant probability, stated counting convention |
| Poisson | A count over an exposure interval | An appropriate rate model; real counts need not fit it |
Before calculating, state replacement, independence, conditioning, and the unit being counted. Then check a boundary case such as probability zero, probability one, or an empty set of draws. These checks catch many errors that memorizing a formula does not.