Qm
Foundational

How Long the Gambler's Ruin Game Lasts

Beyond just the win probability in gambler's ruin, how many bets should you expect to place before the game ends, a related but distinct question with its own clean formula.

Prerequisites: Gambler's Ruin

The problem. You have $ii and repeatedly bet $1 on fair coin flips against an opponent who has $(Ni)(N-i), until one of you is ruined (reaches $0). The classic gambler's ruin question asks: what's the probability you end up with all $NN? A less commonly asked but equally clean follow-up is: how many bets, on average, does the game last before someone is ruined? That's a genuinely different quantity, and it has its own formula worth knowing.

Setting up the recursion

Let DiD_i be the expected number of remaining bets when you currently have $ii (opponent has NiN-i), with the game ending at i=0i=0 or i=Ni=N. Each bet is one flip, after which you're at i+1i+1 or i1i-1 with equal probability, so:

Di=1+12Di1+12Di+1,D0=DN=0.D_i = 1 + \tfrac12 D_{i-1} + \tfrac12 D_{i+1}, \qquad D_0 = D_N = 0.

The "+1" accounts for the bet you just placed to get there. This is a linear recursion, and the classic solved form for a fair game is:

Di=i(Ni).D_i = i(N-i).

In plain English: the expected number of bets is your current stake times your opponent's stake, a simple product, peaking when the two players are evenly matched and shrinking toward zero as either side approaches having all the money (little left to fight over).

Worked example: even match vs lopsided match

Say the total pot is N=20N = 20 and you start with i=10i = 10 (an even match). Expected duration: D10=10×10=100D_{10} = 10 \times 10 = 100 bets. Now suppose you start with only i=2i = 2 against an opponent with $18. Expected duration: D2=2×18=36D_2 = 2 \times 18 = 36 bets, much shorter, because with only $2 to lose, you're very likely to be ruined quickly, and there simply isn't much room for a long back-and-forth. Notice the game lasting the longest happens exactly when it's most evenly matched, which matches intuition: an even fight has the most "room" to swing back and forth before anyone runs out.

Worked example: checking against N=4N=4, i=2i=2 by hand

With N=4N=4, formula gives D2=2×2=4D_2 = 2 \times 2 = 4 expected bets. Verify with the recursion directly: by symmetry D1=D3D_1 = D_3. Writing out D1=1+12D0+12D2=1+12D2D_1 = 1 + \tfrac12 D_0 + \tfrac12 D_2 = 1 + \tfrac12 D_2 and D2=1+12D1+12D3=1+D1D_2 = 1 + \tfrac12 D_1 + \tfrac12 D_3 = 1 + D_1 (using D1=D3D_1=D_3), substitute: D2=1+(1+12D2)=2+12D212D2=2D2=4D_2 = 1 + (1 + \tfrac12 D_2) = 2 + \tfrac12 D_2 \Rightarrow \tfrac12 D_2 = 2 \Rightarrow D_2 = 4. Matches the formula exactly.

Function explorer
-2222.0
x = 1.00f(x) = 2.000

Di=i(Ni)D_i = i(N-i) is a downward-opening parabola in ii, which is exactly the shape on the explorer above, peaking at the midpoint and falling to zero at both ends. Drag the curve and notice the peak always sits exactly halfway between the roots, matching where i=N/2i=N/2.

The general technique

This is the same "set up a recursion, use boundary conditions, solve" method that answers the win-probability version of gambler's ruin, just tracking a different quantity (expected steps rather than absorption probability). The lesson that generalizes: for any absorbing random walk, both "probability of which boundary you hit" and "expected time until you hit a boundary" satisfy their own linear recursions with the same boundary conditions, and both tend to have clean closed forms for a fair (unbiased) walk.

In fair-coin gambler's ruin with stakes $ii and $(Ni)(N-i), the expected number of bets until ruin is Di=i(Ni)D_i = i(N-i), maximized when the two sides are evenly matched and shrinking to zero as one side nears having everything.

Sanity-check any gambler's-ruin duration answer against the symmetric case i=N/2i = N/2: that's where the game should last longest, since i(Ni)i(N-i) is maximized at i=N/2i = N/2.

Discussion

Sign in to join the discussion · reading is open to everyone

💡 Discussion rules

  1. Ask and answer about this concept. Off-topic gets removed.
  2. No homework dumps. Show what you tried first.
  3. Corrections are welcome. Cite a source when you claim an error.

Loading discussion…

Related concepts

Practice in interviews

Further reading

  • Feller, An Introduction to Probability Theory, vol. 1, ch. 14
ShareTwitterLinkedIn