Study 02 · model validation

Gambler’s ruin: closed form versus simulation

A 140,000-trial check of the gambler’s ruin formula against deterministic simulation on European roulette even-money odds.

Gambler’s ruin gives a closed-form answer to a practical question: starting between zero and a target, which boundary is reached first? We used European roulette even-money odds and checked the equation against 20,000 simulations at each of seven starting balances.

140,000
Simulated walks
0.453%
Largest absolute error
48.649%
Win probability per step
50 units
Target boundary

The equation under test

Let p = 18/37 and q = 19/37. Starting at i units with absorbing boundaries at zero and N, the probability of hitting zero first is((q/p)^i − (q/p)^N) / (1 − (q/p)^N). The formula assumes fixed one-unit bets, independent outcomes, no table limits, and no change of strategy after a streak.

Master seed
0x6d592cbb
Trials per start
20,000
Starting units
5, 10, 20, 25, 30, 40, 45
Boundaries
0 and 50 units

Formula and simulation agree

StartExact ruinSimulated ruinAbs. errorMean steps
5 units97.772%97.740%0.032%144
10 units94.852%94.980%0.128%275
20 units86.011%86.330%0.319%477
25 units79.440%79.360%0.080%544
30 units70.830%70.635%0.195%573
40 units44.763%44.310%0.453%456
45 units25.388%25.435%0.047%286
Start 5 units
97.740%
Start 10 units
94.980%
Start 20 units
86.330%
Start 25 units
79.360%
Start 30 units
70.635%
Start 40 units
44.310%
Start 45 units
25.435%
Bar lengths share one scale within this figure. Exact values appear at right.

At 25 units, halfway to the target, a fair coin would imply 50% ruin. The single zero changes that result to 79.44%. The simulation landed within 0.453% of the closed form at every starting point. That agreement is useful: it checks the simulation against a result derived outside the codebase.

Limitations

The model is deliberately narrow. Bets are one unit, wins and losses move the bankroll by one unit, and neither boundary moves. Real betting progressions violate those assumptions. Finite simulation also has sampling error, so a small mismatch is expected. The result validates this random-walk case; it does not certify every feature in the full simulator.

Audit the numbers.The chart data is checked in as plain CSV; the combined snapshot is also available as JSON.

Sources and implementation references