Probability Techniques

Gambler's Ruin Explained

NeetQuant · August 2026 · 5 min read

A staple, because it connects random walks, martingales and a real intuition about bankroll.

The setup

You start with k units. Each round you win 1 with probability p or lose 1 with probability 1 - p. You stop at 0 (ruin) or at N (target).

The fair case, p = 1/2

Probability of reaching N before 0 is k/N.

The cleanest derivation is the martingale one: your wealth is a martingale, so its expectation is unchanged at the stopping time. If P is the probability of hitting N first:

k = P times N + (1 - P) times 0, so P = k/N.

Expected number of rounds is k(N - k).

This is worth internalising because it is much larger than intuition suggests. Starting at 50 with a target of 100, you expect 2,500 rounds. The game drifts nowhere, so it takes a long time to get anywhere.

The biased case

With p not equal to 1/2, let r = (1 - p)/p. Then the probability of reaching N before 0 is:

(1 - r^k) / (1 - r^N)

The consequence that matters: a small edge compounds into near-certainty over enough rounds, and a small disadvantage into near-certain ruin. The dependence is exponential in the number of units, not linear.

The casino result

Let N go to infinity - the opponent has unlimited funds.

  • If p is at most 1/2, ruin has probability 1. Even a perfectly fair game ruins you eventually against an infinitely rich opponent, because your wealth is bounded below at zero and the walk is recurrent.
  • If p is greater than 1/2, you survive with probability 1 - r^k.

This is the honest mathematical statement of why bankroll management matters more than edge, and it connects directly to the Kelly criterion.

Interview variants

The same problem appears as a random walk between two barriers, as a tennis or table-tennis scoring question, as a market-maker inventory question, and as a "how long until this drunk falls off the cliff" puzzle. Recognise the shape and the formula is immediate.

Practise in stochastic processes.

Keep practising

Practise quant interview questions free

Create a free account to attempt hundreds of questions with hints and answer checking, and to run the timed simulators.

Start practising free

Frequently asked questions

What is the gambler's ruin probability formula?
In a fair game, starting with k units and targeting N, the probability of reaching N before going broke is k/N, and the expected number of rounds is k(N - k). With a biased game the answer becomes exponential in k rather than linear.
Why does a fair game still ruin you?
Against an opponent with unlimited funds, your wealth is bounded below at zero but unbounded above. A recurrent random walk will eventually hit any level, so it eventually hits zero - after which there is no recovery.