(ruin)? For a fair game, the ruin probability is 1 - k/n. For a biased game with win probability p, exact formulas using geometric series give the ruin probability in closed form."}}, {"@type":"Question","name":"Why does the house always win in a biased game?","acceptedAnswer":{"@type":"Answer","text":"When the win probability p is less than 0.5, the expected fortune decreases each round. The gambler's ruin probability approaches 1 as the house bankroll grows relative to the gambler's, because the random walk has a negative drift that inevitably pulls the gambler's total to zero given enough time."}}, {"@type":"Question","name":"What is the connection between Gambler's Ruin and random walks?","acceptedAnswer":{"@type":"Answer","text":"Each betting round is a step in a one-dimensional random walk: +1 with probability p, -1 with probability 1-p. The gambler's fortune traces this walk between absorbing barriers at 0 and n. The ruin probability and expected duration are classic first-passage-time problems for bounded random walks."}} ] }

About Gambler's Ruin

The Gambler's Ruin problem is one of the most celebrated results in probability theory. A gambler starts with k dollars and bets $1 per round against a house holding n − k dollars. The game ends when either player reaches $0. Despite the apparent symmetry, the gambler's finite capital is always at a fatal disadvantage against a richer opponent.

For a fair game (p = q = 0.5), the probability of ruin is exactly:

P(ruin | start at k) = 1 − k/n

For a biased game (p ≠ 0.5, let r = q/p):

P(ruin) = (1 − r^k) / (1 − r^n)

Even a tiny house edge (e.g. p = 0.493 as in roulette) makes r > 1, and the ruin probability rapidly approaches 1. The Kelly Criterion gives the bankroll fraction that maximises long-run growth:

f* = p − q / b

where b is the net payout per $1 wagered. Betting more than the Kelly fraction increases risk exponentially; betting less sacrifices long-run growth rate.

Frequently Asked Questions

  • What is the Gambler's Ruin problem?
    The Gambler's Ruin is a classic probability problem: a gambler starts with k dollars and bets $1 per round against an opponent (the house) with n − k dollars. The game ends when one player reaches $0. The question is: what is the probability the gambler is ruined before winning?
  • What is the ruin probability for a fair game?
    For a fair coin flip (p = q = 0.5), the ruin probability for a gambler starting with k dollars when total wealth is n is P(ruin) = 1 − k/n. So if you have $10 out of $100 total, you have a 90% chance of going broke.
  • What is the ruin probability for a biased game?
    For a biased game where you win each round with probability p and lose with q = 1 − p, the ruin probability is P(ruin) = (1 − (q/p)^k) / (1 − (q/p)^n). When p < 0.5 (house edge), this quickly approaches 1 even for large starting capital.
  • Why does the house always win?
    Casinos maintain a small house edge (e.g. p = 0.493 in roulette). Even a tiny bias makes the ruin probability for the gambler approach 1 as the number of rounds grows. The casino's much larger capital means the effective ratio k/n is always tiny for any individual player.
  • What is the Kelly Criterion?
    The Kelly Criterion gives the optimal fraction f* = p − q/b of your bankroll to bet per round, where b is the odds received (net payout per $1 wagered). Betting the Kelly fraction maximises the long-run growth rate of your bankroll and minimises the risk of ruin.
  • What is the expected duration of the game?
    For a fair game starting at k with total wealth n, the expected number of rounds until the game ends is k(n−k). For a biased game with p ≠ 0.5, the expected duration depends on both the win probability and the ratio q/p.
  • How does starting capital affect ruin probability?
    In a fair game, ruin probability is exactly (n − k)/n: doubling your starting capital halves your ruin probability. In a biased game the effect is much stronger — even doubling k barely reduces ruin probability when there is a house edge, because the (q/p)^k term dominates.
  • What happens when p > 0.5?
    When you have a genuine edge (p > 0.5), the ruin formula gives a ruin probability less than 1 even against an infinitely rich opponent. For example with p = 0.55 starting at k=10 of n=100, the ruin probability drops substantially compared to the fair game.
  • Is the Gambler's Ruin related to random walks?
    Yes — each game is a 1D random walk on the integers {0, 1, …, n} with absorbing barriers at 0 and n. The gambler's wealth at time t is a Markov chain, and the ruin probability is the absorption probability at state 0 starting from state k.
  • What real-world situations follow the Gambler's Ruin model?
    Beyond casinos, the model applies to: stock trading with a fixed strategy, species extinction risk in ecology (population reaching 0), insurance ruin theory, clinical trials (drug 'beating' placebo), and packet collision in network protocols. Any finite-resource competition against a better-capitalised opponent follows similar dynamics.

About this simulation

This simulator explores the classic Gambler's Ruin problem: a gambler with starting capital k bets $1 per round against a house, winning with probability p, stopping only at $0 (ruin) or target n (success). It's a one-dimensional random walk with two absorbing barriers and an exact closed-form ruin probability. Four modes let you watch one walk, batch trials against theory, plot ruin curves for several p values, or explore stake sizing with the Kelly criterion.

🔬 What it shows

Path walk animates a single random walk between the 0 and n barriers. Multi-trial batches many walks and compares simulated ruin percentage with theory. Theory curve plots P(ruin) against k for five win probabilities (0.35–0.65), highlighting your chosen p. Kelly sizing plots log-growth rate g(f) against stake fraction f, marking the optimal Kelly fraction f* with a green dot.

🎮 How to use

Set Win probability p (0.30–0.70), Starting capital k (1–99) and Total wealth n (10–200); k is kept below n automatically. Trials (10–1000) sets the batch size in Multi-trial mode, and Odds b (0.5–5) sets the payout per $1 wagered in Kelly sizing mode. Pause, Reset and Run new trial control the animation.

💡 Did you know?

The gambler's ruin problem was posed as one of five exercises in Christiaan Huygens' 1657 treatise on probability, one of the earliest books on the subject, and wasn't fully solved in closed form until later work by Bernoulli and de Moivre.

Frequently asked questions

What do the four view modes show?

Path walk animates a single walk between the 0 and n barriers. Multi-trial batches walks (eight per frame) and compares simulated versus theoretical ruin percentage. Theory curve plots P(ruin) against k for five win probabilities. Kelly sizing instead plots log-growth rate against stake fraction f.

Why can't starting capital k reach or exceed total wealth n?

k is the gambler's stake out of a fixed total n, so it must stay below n for the walk to have somewhere to go; the simulator automatically clamps k to n − 1 if the sliders would push it past n.

Why is the win probability slider limited to 0.30–0.70?

p is the chance of winning each $1 bet. Values near 0 or 1 make the outcome almost certain within a few rounds, flattening the theory curves and multi-trial statistics into uninformative straight lines.

What does the odds slider b change in Kelly sizing mode?

b is the net payout per $1 wagered, used in the growth formula g(f) = p·ln(1+bf) + q·ln(1−f). Raising b increases the optimal Kelly fraction f* = p − q/b; if p is at or below 0.5 the mode reports there is no edge.

How closely does the simulated ruin percentage match the theoretical formula?

Multi-trial mode tallies how many of its batched walks end at 0 versus n. As trials grow, the simulated ruin percentage converges toward the exact formula — 1 − k/n for a fair game, or the (q/p)^k ratio for a biased one — by the law of large numbers.

About the Gambler's Ruin Simulator

The Gambler's Ruin is one of the most celebrated problems in probability theory. A gambler starts with k dollars and repeatedly bets $1 against a house with unlimited (or finite) wealth, winning each round with probability p. The question is: what is the probability that the gambler reaches a target fortune n before going broke? For a fair game (p = 0.5), the ruin probability is exactly 1 − k/n. For a biased game, the formula involves a geometric series: P(ruin) = (1 − (q/p)^k) / (1 − (q/p)^n) when p ≠ 0.5.

The gambler's fortune is a one-dimensional random walk between absorbing barriers at 0 and n. Each bet adds or subtracts 1 from the current fortune, and the walk continues until it hits either barrier. Casino games are biased (p < 0.5), giving the house a statistical edge that makes ruin virtually certain over long play, even for a gambler who starts with substantial capital.

This simulator runs thousands of independent games to build empirical ruin probabilities and expected durations, comparing them to the exact analytical formulas. It illustrates why Kelly-criterion position sizing, stop-loss rules, and finite bankrolls all matter enormously in practice.

Frequently Asked Questions

What is the Gambler's Ruin problem?

A gambler starts with k dollars and bets $1 per round, winning with probability p. The problem asks for the probability of reaching target fortune n versus going broke. For a fair game P(ruin) = 1 − k/n; for a biased game the closed-form result uses the ratio (q/p)^k where q = 1 − p.

Why does even a small house edge guarantee long-run ruin?

A negative expected value per round means the random walk has a downward drift. By the law of large numbers the fortune trends toward zero, and with absorbing barriers the walk is guaranteed to eventually hit 0. No betting system can overcome a negative-EV game in the long run.

How is Gambler's Ruin related to random walks?

Each bet is a step of ±1 in a 1D random walk. The fortune traces this walk between absorbing boundaries at 0 and n. Ruin probability and expected game duration are classic first-passage-time problems for bounded random walks, solved by difference equations or generating functions.

What is the expected number of rounds before the game ends?

For a fair game, the expected duration starting at fortune k with target n is k(n − k) rounds. For a biased game the formula is more complex but still finite. Large bankrolls dramatically increase expected duration even if ruin is eventually certain.

Can the Kelly criterion help avoid ruin?

The Kelly criterion bets a fraction f = p − q of the current bankroll to maximise long-run growth rate and minimise ruin probability. It only applies when you have a positive edge (p > 0.5). For negative-edge casino games no fractional betting system eliminates the long-run ruin guarantee.

About Gambler's Ruin

The gambler's ruin problem is a classic probability puzzle: a gambler starts with capital k and plays repeated games against an opponent with capital N minus k (total table capital N). In each game the gambler wins 1 unit with probability p or loses 1 unit with probability q = 1 minus p. The gambler's goal is to reach N (ruining the opponent); the risk is reaching 0 (being ruined). The probability of eventual ruin from state k is exactly computable from the linear recurrence relation for the ruin probabilities, with elegant closed-form solutions that reveal the profound impact of even a tiny house edge.

For a fair game (p = q = 0.5), the probability of the gambler reaching N before ruin is simply k/N — proportional to starting capital. For an unfair game (p not equal to q), the ruin probability from state k is: P(ruin) = [(q/p)^k minus (q/p)^N] divided by [1 minus (q/p)^N]. In casino games where the house has even a small edge (p slightly below 0.5), a gambler with limited capital against the effectively infinite casino faces certain eventual ruin. The expected game duration before ruin or success also has elegant formulas showing how the random walk's duration scales.

This simulator runs Monte Carlo simulations of the gambler's ruin random walk, showing individual trajectory realizations and the distribution of outcomes (ruin vs. success, duration). You can set win probability, initial and target capital to compare theoretical ruin probabilities against empirical frequencies, observe the dramatic effect of the house edge, and watch many simultaneous random walk trajectories illustrate the distribution of first-passage times.

Frequently Asked Questions

What is the probability of reaching the target before going broke in a fair game?

In a fair game (p = 0.5), the probability of reaching target capital N before ruin, starting from capital k, is exactly k/N. With 10 units of 100 total, you have a 10% chance; with 50 of 100, exactly 50% chance. This elegant result follows from the optional stopping theorem applied to the martingale X_t = gambler's wealth. Despite the simple formula, the path can be extremely long — the expected duration of a fair game with starting capital k targeting N is k times (N minus k) games, which is enormous for moderate N.

How does even a tiny house edge change the outcome?

With a house edge (p slightly below 0.5), long-run ruin is nearly certain for a gambler with finite capital against a casino with effectively unlimited capital. For p = 0.49 (1% edge), the ratio q/p is approximately 1.02, and the ruin probability from state k with very large N is (q/p)^k. Even a 1% edge compounded over thousands of games produces near-certain ruin. This is why casinos with even modest edges (roulette: ~5.3%, blackjack: ~0.5%) are guaranteed profitable in the long run.

What is the connection between gambler's ruin and random walks?

The gambler's ruin problem is equivalent to a one-dimensional random walk starting at position k, asking for the probability of hitting 0 (ruin) before hitting N (success). At each step the walk moves right (+1) with probability p or left (-1) with probability q. The boundary conditions (absorbing barriers at 0 and N) convert the random walk into a first-passage problem. For fair walks (p = 0.5), the walk is a martingale and the optional stopping theorem gives the k/N formula. For biased walks, the geometric solution (q/p)^k arises from the linear recurrence structure.

How long does the gambler's ruin game last on average?

For a fair game (p = 0.5) starting at capital k with target N, the expected number of games is k times (N minus k). With 50 units targeting 100 (100 total), expected duration is 50 times 50 = 2,500 games — surprising longevity given even odds. For an unfair game (p not equal to q), expected duration before ruin is k divided by (q minus p) — finite — confirming that with a house edge, the gambler is ruined in a finite expected time regardless of strategy.

Does the doubling strategy (martingale betting) defeat the gambler's ruin?

The martingale betting strategy — doubling your bet after each loss — guarantees a profit of one unit eventually in a fair game with no betting limits and infinite capital. However, in reality, both conditions fail: casinos have table limits, and gamblers have finite capital. With a table limit, a losing streak wipes out all previous gains in a single catastrophic sequence. The expected profit remains zero (or negative with a house edge), and the doubling strategy merely concentrates risk into rare catastrophic losses while giving frequent small wins — risk transformation, not risk elimination.