Recursive Expectation (First-Step Analysis)
Set up an equation for E[X] by conditioning on the first step of a random process, then solve algebraically.
1. The idea
First-step analysis conditions on the outcome of the very first random step and expresses the target expectation in terms of itself. If the process 'restarts' after a failed step, the resulting equation for is often linear and directly solvable.
This works because many processes (waiting for an event, gambler's ruin, repeated games) are memoryless in structure: after any unsuccessful step, the future looks exactly like the original problem, just with an extra step already used.
The technique generalizes cleanly to accumulating rewards along the way, not just counting the number of steps.
2. Why it matters
First-step analysis is the standard tool for expected number of trials, expected rewards accumulated before an event, and gambler's-ruin-style recursions — a recurring interview category.
3. Core mathematics
Self-referential setup
Example: geometric waiting time, solved for E[X].
General recursion
4. How to recognize it
Think of this when…
- A process repeats until some event occurs (a specific roll, a win, an arrival)
- After a 'failure', the situation is identical to the start
- You are asked for expected number of steps, rolls, or flips, or an accumulated reward along the way
5. Worked example
Worked example
A fair die is rolled repeatedly until a 6 appears. Each non-6 roll adds its value (1 through 5) to a running total, and rolling a 6 ends the process without adding to the total. Find the expected final total.
- 1
Let be the expected total. Condition on the first roll: with probability it's a 6 and the process stops with nothing added; with probability it's uniform on , adding that value and restarting.
- 2
Simplify the sum: , and there are 5 such terms each contributing .
- 3
Solve for .
- Answer: — matches expected number of non-6 rolls (5) times the average added value (3)
6. Common mistakes
- Forgetting to add the reward/cost of the current step before recursing
- Setting up the recursion with the wrong restart probability
- Not simplifying the self-referential equation correctly before solving for
- Ignoring absorbing states (like rolling the target number) and letting the recursion continue indefinitely
7. Quick check
A coin with is flipped until heads appears. What is the expected number of flips?
8. Practice
3 QuantSolve questions use this concept.
Practice this concept9. Related methods
Create a free account to save lesson progress.
Recommended next lessonOptimal Stopping →