A random walk with two walls
The Gambler's Ruin problem imagines a gambler with a starting stake of i units who bets one unit at a time, winning with probability p and losing with probability q = 1-p, and stops as soon as they reach a target of N units (success) or hit zero (ruin). It is one of the oldest solved problems in probability — Pascal and Fermat corresponded about a version of it in 1656 — and it is exactly a random walk on the integers from 0 to N with two absorbing barriers.
The closed-form ruin probability
Let q_i be the probability of eventual ruin starting from stake i. A single step either wins (moving to i+1 with probability p) or loses (moving to i-1 with probability q), giving the recurrence q_i = p·q_{i+1} + q·q_{i-1} with boundary conditions q_0 = 1 and q_N = 0. Solving that recurrence — a standard second-order linear difference equation — gives a strikingly different answer depending on whether the game is fair:
fair game (p = 0.5): P(ruin | start at i) = 1 - i/N # purely proportional to stake unfair game (p != 0.5), r = q/p: P(ruin | start at i) = (r^i - r^N) / (1 - r^N)
Two facts drop straight out of this formula and both are counter-intuitive at first. First, even in a perfectly fair game (p = 0.5), a gambler playing against an opponent with effectively unlimited funds (N → ∞) is ruined with probability 1 — no finite stake ever guarantees survival against an infinite bankroll, however favourable each individual bet looks. Second, when the game is even slightly unfavourable (p < 0.5), the ruin probability climbs exponentially fast as N grows, because r = q/p > 1 and r^N dominates the formula — a small house edge compounds brutally over a long session.
Expected duration and why 'playing longer' is the trap
The expected number of bets before the game ends also has a closed form; in the fair case it is i(N-i), maximized when the stake sits exactly halfway to the target — meaning the most drawn-out, suspenseful games are also the ones where luck alone decides everything. In the unfavourable case the expected duration is finite too, but the point that matters practically is that the longer you play a negative-expectation game, the closer your probability of ruin gets to 1 — the house edge does not need to be large to be decisive, it just needs the number of bets to be large, and casinos are built on exactly that asymmetry: a player wants a short, exciting session; the house wants millions of bets across millions of players over years.
The Kelly criterion: betting size as the real lever
Gambler's Ruin is also the mathematical foundation of the Kelly criterion, developed by John Kelly in 1956 while at Bell Labs. If a bet has positive expected value, the question is no longer whether to bet but how much of your bankroll to risk each time. Betting too little leaves growth on the table; betting too much reintroduces a nontrivial probability of effective ruin even with a favourable edge, because a large enough single loss can wipe out a bankroll faster than a string of favourable bets can rebuild it. Kelly's formula, f* = (bp - q)/b (b = net odds, p = win probability, q = 1-p), maximizes the long-run exponential growth rate of the bankroll while keeping the ruin probability at exactly zero for an infinitely divisible bankroll — in practice, bettors use a fraction of full Kelly to control variance.
Monte Carlo verification
Because the closed-form solution is a clean recurrence, it is easy to sanity-check with simulation: run thousands of independent random walks from the same starting stake with the same p, and count what fraction hit 0 before hitting N. For any reasonable sample size, the simulated ruin fraction converges to the formula's prediction, which is a satisfying, tangible way to see the law of large numbers operating on top of a random walk that itself never converges to anything — each individual path is wildly unpredictable, but the aggregate statistic is exactly predictable.
Frequently asked questions
Can a gambler with a real edge (p > 0.5) still go broke?
Yes, though the probability shrinks fast as the stake grows relative to the target: with r = q/p < 1, ruin probability is (r^i - r^N)/(1 - r^N), which falls off roughly geometrically in the starting stake i. A positive edge lowers the danger dramatically but never removes it outright for a finite bankroll facing any nonzero risk per bet.
Why is a fair coin-flip game against a casino still a losing proposition long-term?
A real casino game is never exactly p = 0.5 — the house edge (e.g. the green zero on roulette) tilts p slightly below 0.5 for the player. Because the ruin probability against an effectively unlimited house bankroll approaches 1 as the number of bets grows, even a tiny unfavourable edge becomes overwhelming given enough spins.
What does the Kelly criterion have to do with Gambler's Ruin?
Gambler's Ruin shows that betting too large a fraction of your bankroll on each wager, even with a favourable edge, creates a real risk of catastrophic loss. The Kelly criterion answers the follow-up question directly: it calculates the exact bet fraction that maximizes long-run bankroll growth while keeping the ruin probability at zero for a divisible bankroll.
Try it live
Everything above runs in your browser — open Gambler's Ruin and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.
▶ Open Gambler's Ruin simulation