Formula: Gambler’s Ruin Probability Formula
- startingBankrollUnitsI: Starting Bankroll Units I (units)
- targetGoalBankrollUnitsN: Target Goal Bankroll Units N (units)
- singleBetWinProbabilityPct: Single Bet Win Probability Pct (%)
Compute probability of hitting target bankroll N before ruin (0) and expected steps.
Because the bankroll is measured in betting units, so a bigger bankroll at the same stake means more bets, and each bet gives the house edge another chance. Doubling 100 units at the default p gives under half a percent success, against 25.346% for 20 to 40. Holding the ratio fixed while adding steps lets the drift dominate.
For a biased game, take the start i, subtract the target N times the success probability, and divide by q minus p. For the default that is 20 minus 40 times 0.25346, divided by 0.027, about 365 bets. For a fair game it is simply i times N minus i, so a walk from 20 to 40 averages four hundred bets.
It is close to 18 out of 37, the probability of winning an even money bet on a single zero roulette wheel. A double zero wheel gives 18 out of 38, about 47.37%. I ran that value with the default 20 and 40 units and the success chance fell to 10.852%, less than half the single zero figure.
The baseline is i divided by N, the success probability if each bet were a true coin flip. It equals 50% only when you start exactly halfway to the goal. Starting at 12 of 40 gives a 30% baseline and starting at 30 gives 75%. Compare it with the main result to see how much the edge costs.
No. The formula assumes each bet moves the bankroll up or down by exactly one unit. A bet paying several times the stake, or one with a push outcome, needs a different model with uneven steps. Simulating the game, or using a Markov chain with the actual payout steps, is the right approach for those cases.
Yes, and often more usefully. Lowering the target shortens the walk you must win. A walk from 20 to 21 at the default p gives 92.249% success, since you only need to get one unit ahead before falling 20 behind. The trade is a small possible gain against a small chance of losing everything.
The walk moves one unit at a time, so only whole positions exist between 0 and N, and the tool asks for whole numbers in both bankroll fields. If your stake does not divide your bankroll evenly, choose the unit size first and then round the bankroll down to a whole number of units, since a partial unit cannot be bet in this model.
Not by the choices this model allows. Bet sizing changes how much of the fair game probability you keep, and bold play keeps the most, but every result stays below the fair baseline. With p at 48.65%, a single bet of everything gives 48.65%, which is the best a doubling attempt can reach.
Very. The figure shown is a mean. A game from 20 to 40 can end after 20 straight losses or run for well over a thousand bets if the bankroll keeps hovering near the middle. The distribution has a long right tail, so the typical game is somewhat shorter than the average and a few are much longer.
The edge is now in your favour. With 20 units aiming at 40, success rises to 83.214% and ruin falls to 16.786%, over a little more than three hundred expected bets. In a favourable walk, many small bets are better than a few large ones, because the positive drift has more steps to work.
About 10 units. You end at 40 with probability 25.346% and at 0 otherwise, so the average is 40 times 0.25346, a little over 10. You started with 20, so the expected loss is around 10 units across about 365 bets, roughly 0.027 per bet. That per bet loss is exactly q minus p, the edge against you.
The default asks a classic question. You hold 20 units, you want to reach 40, and every bet wins one unit with probability 48.65% or loses one unit otherwise. What are the odds you double up before you go broke?
The answer is 25.346%. Ruin, the other outcome, is 74.654%. The two always add to 100% because the walk must end at one boundary or the other; with probability one it cannot wander forever between them.
The 48.65% default is not arbitrary. It is very close to 18 divided by 37, the chance of winning an even money bet on a single zero roulette wheel. So the default is, in effect, someone trying to double a bankroll of 20 chips one chip at a time on red or black.
The fair game baseline next to it, 50%, is what the same starting point would give if each bet were a true coin flip. The gap between 50% and 25.346% is the cost of a house edge of under three percent per bet, compounded over hundreds of bets. That gap is the whole lesson of the calculation.
Write p for the win probability and q for 1 minus p. With p at 48.65%, q is 51.35%, and the ratio q/p is about 1.0555. That ratio is the engine of the whole result.
Raise it to the starting bankroll: 1.0555 to the 20th is about 2.945. Raise it to the target: to the 40th is about 8.675. The page's formula is one minus the first, divided by one minus the second. That is minus 1.945 over minus 7.675, which is 0.2535, or 25.35%, matching the output to rounding.
When p is exactly 50%, q/p is 1, the formula would divide zero by zero, and the tool switches to the simple version: i divided by N. With 20 and 40 that gives 50%. I ran p at 49.99% to check the two formulas join up smoothly, and it returned 49.8%. So the biased formula really does converge on the fair one as the edge shrinks.
The ratio also shows why a small edge matters so much. It is raised to the power of the bankroll. A ratio barely above 1, raised to the 40th, is already more than eight. Larger bankrolls measured in betting units make that power larger still.
The third line is the average number of bets before the game ends, at either boundary. For the default it is 365.25.
For a biased walk there is a neat formula. Take the starting bankroll, subtract the target times the probability of reaching it, and divide by q minus p. For the default that is 20 minus 40 times 0.25346, or about 9.86, divided by 0.027, which gives about 365 bets, matching the page.
For a fair game the expected duration is simply i times (N minus i). With 20 and 40 that is 20 times 20, four hundred bets. I ran it at 50% and got exactly that.
So the house edge does two things at once: it lowers the chance of success and shortens the game, because the drift towards zero ends more walks early. A small rise in p the other way also shortens it. At 52% the tool gives a little over three hundred expected bets alongside an 83.214% chance of success.
Remember this is an average over many possible games. Any single attempt could end in 20 bets with a straight losing run, or go on for well over a thousand. The distribution of durations is wide and skewed to the right.
The lower preset starts with 12 units instead of 20, still aiming at 40. Success falls to 11.882% and ruin rises to 88.118%, over about 268 expected bets. On a fair coin the same start would give 30%, so the house edge has taken away more than half of a fair game's chance.
The higher preset starts at 30 units. Success is 52.83%, ruin 47.17%, and the expected length is 328.442 bets. The fair baseline here is 75%. Even three quarters of the way to the goal, a slightly unfavourable bet leaves the outcome close to a coin toss.
Read side by side, the three presets show that starting closer to the goal helps, but much less than intuition suggests. The fair game numbers rise in a straight line with the start. The biased ones curve below that line, and the further you are from the goal, the further below it they sit.
The units in this calculator are betting units, not money. If you hold a cash bankroll and aim to double it, staking a twentieth of it per bet is a walk from 20 to 40 units. Staking a quarter of it per bet is a walk from 4 to 8. Staking half of it is a walk from 2 to 4.
Rescaling like this changes the answer a great deal. At the default p, a walk from 10 to 20 gives 36.816%. From 5 to 10 gives 43.289%. From 2 to 4 gives 47.302%, very close to a single bet of the whole bankroll at 48.65%.
This is the well known result that in an unfavourable game, bold play beats timid play. Fewer bets means fewer chances for the house edge to work. It does not make the game favourable; every one of those numbers is below 50%. It just loses less of the fair game probability.
The reverse holds when p is above 50%. Then small bets and many steps let the positive drift accumulate, and the tool shows the success probability climbing towards 100% as the bankroll in units grows. A walk from 20 to 40 at 52% already reaches 83.214%.
The calculator checks its inputs and refuses ones that do not describe a valid walk, rather than quietly changing them. The starting bankroll must be a whole number of at least 1 unit. A start of 0 returns a check inputs message, since a player with nothing has already been ruined.
The target must be a whole number above the start, within a generous upper limit on size. If you type a start of 50 and a target of 40, you get an error, not an answer to some nearby question. Decimals in either field are rejected too, because the walk moves one unit at a time and only whole positions exist.
Win probability must sit strictly between 0% and 100%. Exactly 0 or 100 would make the walk certain, so the formula has nothing to compute. Values just inside the range still run. At 1% the result shows 0% success and about 20 expected bets, close to the 20 straight losses the walk needs, and a start of 1 unit at the default p gives 0.723% success in about 26 expected bets.
Those edge runs are useful as sanity checks. If a result looks strange, try an extreme where you already know the answer, and confirm the tool agrees before trusting a figure in the middle of the range.
Most people look at the success line first, but the ruin line is the one that describes what usually happens. At the default it says 74.654%: in roughly three games out of four, the 20 units are gone before the 40 is reached.
That figure also tells you what you should expect to walk away with on average. Win and you hold 40 units; lose and you hold none. With a 25.346% chance of the first, the average finishing bankroll is a little over 10 units, roughly half of what you started with. In a fair game the average would be exactly 20, the starting bankroll, which is what fair means.
The loss of about 10 units on average is spread over an expected 365.25 bets, which works out to roughly 0.027 units lost per bet. That is exactly q minus p, the house edge per unit staked. The ruin probability, the duration and the edge all fit together, and checking one against the others is a good way to confirm you have entered the inputs you meant.
If the ruin probability looks too high to accept, the levers are a closer target, bigger stakes relative to the bankroll, or not playing at all. A larger bankroll at the same stake, as the presets show, does not lower it much and can raise it when the target rises with it.
The model has three strict assumptions. Every bet is the same size, every bet has the same win probability, and a win pays exactly what a loss costs. Many real wagers break at least one of those.
Bets that pay more than even money, such as a single number on roulette, move the bankroll by more than one unit on a win. The walk is then no longer one step up or one step down, and this formula does not apply. Games where the odds change with each hand, or where the player changes stake after wins and losses, are outside the model too.
Outside the casino, the same mathematics describes a trader with a fixed risk per trade, a sequential test that stops at one of two thresholds, or any process that drifts until it hits a barrier. In each case the formula is only as good as the assumption that each step is independent and identically distributed.
Nothing here is advice to gamble. The calculator is most useful for showing, in plain numbers, why a negative edge cannot be overcome by persistence or bankroll size.