The idea
First-step analysis solves hitting problems with a system of linear equations, one per state. A martingale does the same job with one equation. If is a martingale and you stop at a well-behaved time , then
At the stopping time you usually know where the walk is (on one of the barriers), so this single equation pins down the unknown probability or expectation. The skill is picking the right martingale.
Martingales from a random walk
Let with i.i.d. steps with probability and with probability . The step has mean and variance .
| Martingale | Why | Used for |
|---|---|---|
| subtract the drift | expected durations (Wald) | |
| subtract the variance | durations of fair walks, variances | |
| ruin probabilities of biased walks | ||
| , | normalise by the MGF | distribution of |
For the fair walk () the first two become and .
To check a candidate, compute by writing and averaging over the one new step.
The optional stopping theorem
Let be a martingale and a stopping time. Then if any one of these holds:
- is bounded: for some constant .
- almost surely and the stopped process is bounded: for all .
- and the increments are bounded: .
For a walk between two barriers, condition 2 covers and (both bounded until absorption). For and , use condition 3 or apply the theorem to the bounded time and let .
When it fails. A fair walk started at 0 hits eventually with probability 1. Stop there: , so . None of the conditions holds: is unbounded, is unbounded below, and . This last fact drops out of the failure itself: if were finite, condition 3 would force .
The doubling strategy (double your stake after each loss, stop at the first win) is the same trap. It wins one unit with probability 1, but only by allowing unbounded losses along the way and unbounded time. With any credit limit or time limit, condition 1 or 2 applies and the expected gain is exactly zero.
Gambler's ruin by martingales
Start at 0 with absorbing barriers at and , and let .
Fair walk. From : , so . From : .
Biased walk. Put . From :
Then Wald's identity (optional stopping for ) gives the duration without solving any recurrence:
One barrier. Let in the formula for with (so ): the probability of ever falling to is . With , the probability of ever rising to is . And with , the time to reach has
To justify this, apply Wald at the bounded time : , so by monotone convergence, and then Wald applies at itself, where exactly.
Worked example
a biased walk between two barriers
A walk starts at 0 and steps up with probability , down with probability . It stops at or . Find the probability it stops at and the expected number of steps.
Show solutionHide solution
Here , so is a martingale. It is bounded between and until absorption, so optional stopping applies:
For the duration, and
Solving the seven first-step equations with exact fractions gives the same and .
Sanity checks. is well above the fair-walk value , as the drift should make it. The duration is below the one-barrier value , because the lower barrier sometimes ends the game early.
Wald's second identity: variances
Optional stopping for gives Wald's second identity: if ,
For a one-sided hit with , , so the left side is . Hence
The cube in the denominator matters: a small edge makes the hitting time not just long but extremely variable.
Worked example
how long to make five dollars?
You win each $1 bet with probability and have unlimited credit. Find the mean and standard deviation of the number of bets until you are first $5 up.
Show solutionHide solution
and .
The standard deviation is bets, about the same as the mean: the distribution has a long right tail from paths that dip early. An exact computation of the distribution of gives mean and variance .
Also: the probability of ever being $2 down is , even though you are certain to be $5 up eventually.
Waiting for a pattern: the casino martingale
How many fair coin flips until HTH first appears? Imagine a gambler arriving before every flip with $1, betting it all that the next flip starts the pattern (H), and if he wins, betting everything on the next letter, and so on. Each bet is fair, so the casino's net takings are a martingale with mean zero, and optional stopping applies because the waiting time has finite mean.
When HTH first completes at time , the house has received dollars. Who is still holding money?
- The gambler who arrived at flip has won three doubles: $8.
- The gambler who arrived at flip bet on H and lost.
- The gambler who arrived at flip won one bet on H: $2.
Everyone else has lost. So and .
In general over every for which the length- prefix of the pattern equals its length- suffix (the whole pattern included). HTH has overlaps of length 3 and 1, giving . HHH has 3, 2 and 1, giving ; HHT has only 3, giving .
Knowledge check
A fair ±1 walk starts at 0 and stops at −3 or +7. What is the expected number of steps?
Knowledge check
A walk steps up with probability 0.6 and down with probability 0.4, starting at 0 with no barriers. What is the probability it ever reaches −2?
Knowledge check
A fair walk from 0 is stopped when it first hits +1, so E[S at the stopping time] = 1, not 0. Why does optional stopping fail?
Key takeaways
- Pick a martingale, stop it, and read off one equation: and give probabilities; and give durations.
- Optional stopping needs a bounded time, a bounded stopped process, or a finite mean time with bounded steps. The fair walk hitting and the doubling strategy fail all three.
- Fair walk between and : , . Biased: solve , then .
- One barrier with : , , and .
- Pattern waiting times: sum over the self-overlaps of the pattern (HTH: 10, HHH: 14).
Practice problems
Finished reading?
Answer the 3 knowledge checks to complete this lesson (0 done).