Double or nothing
You walk into a casino with $5. You bet $1 on each round of a fair coin flip. If it's heads, you gain $1. Tails, you lose $1. You keep playing until you either reach $10 or go broke.
Run the simulation. Watch the gambler's fortune trace a path between $0 and the goal:
With a fair coin, the ruin probability is 50%. Starting halfway to the target gives a symmetric outcome. But what happens when the game is slightly unfair?
The house edge changes everything
Casinos don't offer fair bets. Roulette gives you roughly a 47.4% chance of winning an even-money bet (because of the green zero). That 2.6% edge seems tiny.
Go back to the simulator, slide the win probability down to 47%, and watch what happens. The paths tend to drift downward.
The formula
The gambler's ruin has a closed-form solution.
A gambler starts with $ and bets $ per round. Each round is won with probability and lost with probability . The game ends when the gambler reaches $ or $.
Fair game ():
Unfair game ():
Explore how ruin probability changes with starting money and win probability:
When , the curve bows upward: even generous starting positions barely help. When , the curve bows downward: even modest starting capital gives strong protection. The shape of this curve is an exponential, not a line.
Why "just quit while ahead" doesn't work
People often suggest: "Win a few, then leave." The gambler's ruin shows why this intuition fails.
The math is merciless: if , the longer you play, the more certain your ruin becomes. As the target grows, the ruin probability approaches 1, regardless of starting capital.
For and :
This is why casinos are profitable businesses. They have an infinite bankroll and a slight edge. Time is on their side.
Competition appearances
The gambler's ruin shows up across math competitions and programming contests:
Math competitions:
- Putnam problems on absorbing Markov chains often reduce to gambler's ruin
- AIME/USAMO problems involving sequential games with stopping conditions
- Physics olympiads use the same recurrence for particle diffusion
Programming challenges:
- Project Euler problems on random processes with absorbing barriers
- Codeforces rating problems: "probability a player reaches rating X before dropping to Y"
- Interview questions at quant trading firms: this is a favorite at Jane Street and Two Sigma
Related probability results:
- With a fair coin and no upper barrier (), the walk returns to 0 with probability 1 but the expected time to return is infinite
- In 2D, a random walk also returns to the origin with probability 1
- In 3D and higher, the walk escapes to infinity with positive probability (Polya's recurrence theorem)
The takeaway
The gambler's ruin comes down to this: a small per-round disadvantage, compounded over many rounds, becomes near-certain defeat. The recurrence is a building block for Markov chain analysis, and the exponential solution shows up wherever you have biased random walks with absorbing barriers. In competitions, when you see a process that can end in "win" or "lose" states with probabilistic transitions, think gambler's ruin.