Practice Set: Probability Puzzles
Explore common probability puzzles used in data science interviews by defining events, calculating exact probabilities, and validating results with simulations. Learn to explain assumptions and reasoning clearly while solving for scenarios like coin toss sequences, dice outcomes, card draws without replacement, birthday collisions, expected value in games, and the Monty Hall problem.
Approach probability problems by defining the event of interest, identifying the possible outcomes, and deriving the probability before applying a formula. For each problem, explain the setup and assumptions before calculating the probability. This allows the interviewer to evaluate the reasoning rather than just the final answer. A Monte Carlo simulation can provide an independent numerical check of the analytical result, but it does not replace the mathematical reasoning required to derive the answer.
The six problems cover the probability of an exact coin-toss sequence, conditional probability with dice, card draws without replacement, the birthday problem, an expected-value game, and a conditional probability problem involving new information. Each problem includes two hints, a step-by-step analytical derivation, a reasonableness check, an optional numerical verification using NumPy, and a follow-up question that modifies the original conditions. Attempt each problem independently before reviewing Hint 1, Hint 2, and the full derivation, in that order.
Problem 1: HHT in three flips
Scenario: In the first problem, a fair coin is flipped three times. Calculate the probability of obtaining the sequence HHT (heads, heads, tails) in that exact order. Each flip is independent, with a probability of 1/2 for heads and 1/2 for tails.
Question: What is the probability of seeing HHT in that exact order in three flips of a fair coin?
Solution
The event is the one ordered sequence HHT, not any sequence with two heads and one tail.
The same result follows from sample-space counting. Three flips produce HHT.
The answer is below TTT or THH; order changes the event but not its probability.
Optional simulation check:
Code explanation:
rng: A random generator with a fixed seed, so every run produces the same numbers.flips: 100,000 rows of three flips each, with 1 for heads and 0 for tails.(flips == [1, 1, 0]).all(axis=1): Marks each row that matchesHHTexactly, andnp.meanturns those matches into a proportion.
This prints a value near 0.125.
Follow-up question: We keep flipping until HHT first appears. How many flips does that take on average?
Answer: The probability HHT when it fails. Track how much of the pattern we have built. Let H, and