First-Step Analysis
A recipe for computing hitting probabilities and expected waiting times in random processes — condition on what happens in the very first step, write the unknown in terms of itself, and solve.
Prerequisites: Markov Chains, Conditional Probability
First-step analysis is the workhorse technique for a huge family of interview questions: "how likely is this to happen before that?" and "how long, on average, until it happens?" The idea is almost embarrassingly simple. You don't know the answer directly, so you condition on the one thing you can reason about — what happens on the very first step — and use the fact that after that step you're facing a smaller version of the same problem. That self-reference turns the question into an equation you can solve.
It's nothing more than the The Law of Total Probability (for probabilities) or its cousin for expectations, applied one step at a time. But naming the move and drilling it is what makes hard-looking Markov questions fall over in two lines.
The recipe
Let be the quantity you want — a probability of reaching some goal, or an expected time — starting from state . Condition on the first transition: from you move to state with probability , and from you face the same problem with value . That gives one equation per state:
The only difference is the : computing a time, you charge yourself one step for having taken the first move, then add the expected time remaining. Pin down the boundary conditions — the values at the absorbing states you're measuring to — and you have a small linear system. Solve it.
Condition on the first step: for a hitting probability, and for an expected time. The pays for the step you just took. Add the boundary values and solve the resulting equations.
Worked example: waiting for two heads in a row
Flip a fair coin until you see two heads in a row (HH). How many flips on average? Set up three states by how much progress you've made toward HH:
- S — no useful progress (start, or you just flipped a tail).
- A — the last flip was a heads (one away from done).
- HH — done. This is the absorbing state; its expected remaining time is .
Let and be the expected flips to reach HH from each state. Reading the transitions off the diagram and charging per flip:
From the first equation, , so . Substitute into the second: , giving , so and . On average it takes 6 flips to see two heads in a row.
The surprise: waiting for HT instead takes only 4 flips. The same recipe on the HT machine gives , because a tail after a head completes the pattern instead of destroying your progress. Patterns that can overlap themselves (like HH) take longer to appear — a genuinely counterintuitive result that first-step analysis makes obvious.
The waiting-time surprise: HH takes 6 flips on average, HT only 4. Whenever a target pattern can partially overlap itself, a "miss" costs you more progress, so it takes longer to arrive. First-step analysis is how you prove which patterns are slow.
Worked example: gambler's ruin in one line
The same method derives the Gambler's Ruin result cleanly. Let be the probability of reaching before from bankroll , with a fair coin. Conditioning on the first bet:
This says is the average of its neighbors, which forces the solution to be a straight line, and the only straight line hitting at and at is . The famous ruin probability drops straight out of the recipe.
Two mistakes sink first-step analysis: forgetting the boundary conditions (without them the equations have infinitely many solutions), and dropping the when you're computing an expected time rather than a probability. Also confirm the process actually reaches its target with probability one, or the "expected time" can be infinite.
Where it fits
First-step analysis is the elementary, no-machinery route to results that optional stopping reaches with martingales. It computes hitting probabilities, expected absorption times, and expected rewards for any Markov chain, and it's the fastest tool to reach for the moment a problem mentions "first time" or "before."
Related concepts
Practice in interviews
Further reading
- Ross, Introduction to Probability Models, ch. 4
- Grimmett & Stirzaker, Probability and Random Processes, ch. 6