Simulation Playground

Gambler's Ruin

Simulating the probability of winning or going bankrupt in sequential betting

Parameters

$10$90
$60$200
10%90%
$1$10
101,000

Visualization

Run the simulation to see the gambler's fortune over time

How It Works

The Gambler's Ruin problem models a gambler who starts with an initial stake and makes a series of bets, winning or losing a fixed amount with certain probabilities.

The Scenario:

  • A gambler starts with $50 (initial funds)
  • Each bet has a 50% chance of winning and a 50% chance of losing
  • The gambler wins $1 or loses $1 on each bet
  • The gambler continues betting until either reaching the goal ($100) or going bankrupt ($0)

Mathematical Analysis:

For a fair game (50% win probability), the probability of reaching the target goal before bankruptcy is proportional to the initial funds divided by the goal. As the win probability changes, this relationship becomes non-linear.

The simulation runs multiple trials and tracks the outcomes to estimate the actual probability of success and the average number of bets needed to reach either outcome.

Deeper Statistical Insights:

We compute not only average steps but also the variance in steps, which shows how spread out the outcomes are. A higher variance indicates more unpredictability in reaching a final outcome.

We also use logarithmic scaling via log1p to calculate the log-transformed values of starting funds and goal. These can be useful in strategies like Martingale where the impact of multiplicative growth or loss is significant.