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.
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
| Start | Exact ruin | Simulated ruin | Abs. error | Mean steps |
|---|---|---|---|---|
| 5 units | 97.772% | 97.740% | 0.032% | 144 |
| 10 units | 94.852% | 94.980% | 0.128% | 275 |
| 20 units | 86.011% | 86.330% | 0.319% | 477 |
| 25 units | 79.440% | 79.360% | 0.080% | 544 |
| 30 units | 70.830% | 70.635% | 0.195% | 573 |
| 40 units | 44.763% | 44.310% | 0.453% | 456 |
| 45 units | 25.388% | 25.435% | 0.047% | 286 |
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.
Sources and implementation references
- Feller, W. (1968), An Introduction to Probability Theory and Its Applications, Vol. 1, Chapter XIV.
- Thorp, E. O. (1969), Optimal Gambling Systems for Favorable Games.