Gambler's ruin calculator
Say you've got i units and you bet one unit at a time, winning each bet with chance p. You stop when you reach N or when you've lost everything. Put in your numbers and you'll see your chance of reaching N and how many bets the game lasts on average, with a quick simulation next to both so you can check them.
| Formula | Simulation | |
|---|---|---|
| Chance of reaching N | ||
| Chance of going broke | ||
| Expected number of bets |
The formulas
Write q = 1 - p and r = q / p. In a fair game, p = 1/2, your chance of reaching N is i / N and the game lasts i(N - i) bets on average. Otherwise your chance is (1 - ri) / (1 - rN), and the expected length is (i - N P) / (q - p), where P is that chance. You get both the same way, by looking at the first bet and solving the recurrence that comes out of it.
I'd try p = 49% with i = 10 and N = 20 first. A one point edge to the house takes your chance of doubling from 50% down to about 40%. If you raise N to 100 it drops below 1%, which I think surprises most people the first time.
More probability questions of this kind, with worked answers: quant interview probability questions