Module 2.5 · Counting and Probability
Probability with states
Many probability problems describe a process that could, in principle, go on forever: flip until a pattern appears, walk until you hit a wall, play until someone is two points ahead. You can't list all the outcomes, but you can describe where the process is right now with a small number of states and write one equation per state.
States and first-step analysis
A state records everything about the current situation that matters for the future. For "flip a coin until you see ," the only thing that matters is whether the last flip was . So there are two live states, "start" (or last flip ) and "last flip ," plus the finished state.
First-step analysis
Let be the quantity you want (a probability or an expected count) starting from state . Look at one step of the process:
- For a probability: , with at winning states and at losing states.
- For an expected number of steps: , with at finished states.
Solve the resulting system of linear equations.
The reason this works: after one step, the process "restarts" from the new state, and it has no memory of how it got there. So the future from state is worth , no matter what happened before.
Definition
Absorbing state
A state the process never leaves, such as "pattern found" or "player is broke." Probability problems ask which absorbing state you reach; expected value problems ask how long it takes to reach one.
Gambler's ruin
A player has dollars and repeatedly bets dollar, winning with probability and losing with probability , until reaching or . With the probability of reaching , first-step analysis gives , with and . The solution is
Patterns in coin flips
For waiting times of patterns, the states are "how much of the pattern have I matched so far?" The subtle part is what happens after a wrong flip: you may still have matched a shorter piece. For , if you have and flip , you're back to nothing; but if you have and flip , you still have .
Common mistake
When a flip breaks a partial match, don't automatically drop back to the start. Ask what the longest ending of the flips so far is that is also a beginning of the pattern. Going back too far is the most common error in pattern problems.
Worked example: Waiting for HH
A fair coin is flipped until two heads in a row appear. Find the expected number of flips.
Let be the expected number of further flips from the start (or after a ) and the expected number after an .
The first gives . Substituting, , so and .
Worked example: Gambler's ruin
A player starts with dollar and bets dollar at a time, winning each bet with probability . Play stops when the player has or dollars. What is the probability of reaching ?
Here , so .
Check with equations: , , . Solving gives .
Worked example: A pattern race
A fair coin is flipped until either or appears. What is the probability that appears first?
Think about the first . Once any has appeared, the next completes , and can't happen before that (a right after an makes , not ). So wins only if it appears before any , which means the first two flips are . That has probability , so wins with probability .
States would give the same answer, but look for this kind of shortcut first.
Tip
Symmetry cuts the number of states. On a cube, a bug's position only matters through its distance from the target (, , , or edges), so eight vertices become four states.
Practice
A fair coin is flipped until the sequence appears for the first time. What is the expected number of flips?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Alice and Bob take turns rolling a fair die, with Alice first. The first person to roll a wins. The probability that Alice wins is in lowest terms. Find .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
A fair coin is flipped until either or appears as three consecutive flips. The probability that appears first is in lowest terms. Find .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
A gambler starts with dollars and bets dollar at a time, winning each bet with probability . Play stops when the gambler has or dollars. The probability of ending with dollars is in lowest terms. Find .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
A bug starts at one vertex of a regular hexagon. Each second it moves to one of the two neighboring vertices, each with probability . The probability that it is back at its starting vertex after moves is in lowest terms. Find .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
A bug starts at a vertex of a cube. Each minute it walks along one of the three edges at its current vertex, chosen uniformly at random. What is the expected number of minutes until it first reaches the vertex farthest from its start?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
A fair die is rolled repeatedly, and a running total of the rolls is kept. The probability that the running total is ever exactly is in lowest terms. Find .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
In a game of tennis, the first player to win at least points while being ahead by at least points wins the game. Petra wins each point independently with probability . The probability that Petra wins the game is in lowest terms. Find .
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Real contest practice
- 1985 AIME, Problem 12: a bug walking on a tetrahedron, with the state "at the start vertex or not."
- 2003 AIME II, Problem 13: a bug on a triangle and a two-state recursion for its position.
- 2023 AIME I, Problem 6: an expected number of correct guesses, found by recursion on the cards remaining.