The gambler's ruin

Tivadar Danka small portrait Tivadar Danka

Understanding math will make you a better engineer.

So, I am writing the best and most comprehensive book about it.

One common wisdom about gambling is that the house always wins.

This is not just a catchphrase; there is mathematical evidence behind it. If you play against an opponent with much deeper pockets, your chances of winning approach zero.

Read on to see why!

To illustrate the problem above, consider a simple example: betting on coin tosses.

The dealer tosses a fair coin. If it lands on heads, you win $1\$1. If tails, you lose $1\$1. With each toss, the probability of winning and losing are the same:

P(winning a round)=P(losing a round)=12.P(\text{winning a round}) = P(\text{losing a round}) = \frac{1}{2}.

You have n\textstyle n dollars, while the casino has m\textstyle m. In total, there are N=n+mN = n + m dollars on the table. You win when you reach N\textstyle N dollars. However, if you get to zero, you lose.

The question is simple: what is the probability of winning?

For instance, if you have $3\$3 and the casino has $7\$7 , this is what one possible outcome looks like.

Trajectory of wins/losses in a simple gambling game

(x\textstyle x is the number of rounds, y\textstyle y is your balance.)

This problem is much simpler if we think outside the box and generalize the question. When we ask the probability of winning, conditioned on starting from n $, a recursive relation and its boundary conditions are revealed. To put our idea into a mathematical form, consider the sequence

p(n):=P(winning $Nstarting from $n).p(n) := P(\text{winning }\$N | \text{starting from }\$n).

It is easy to see that p(0)=0p(0)=0 and p(N)=1p(N)=1. What about the rest? For that, notice that when having $n\$n, we either

  • started from $(n+1)\$(n+1) and lost a round,
  • or started from $(n1)\$(n-1) and won a round.

Thus, we obtain the recursive relation

p(n)=12p(n+1)+12p(n1).p(n) = \frac{1}{2}p(n+1) + \frac{1}{2}p(n-1).

Although this seems complicated, the solution is easier than you think! Solving this recursion, we obtain a simple formula: your probability of winning is proportional to the money you have.

p(n)=nN,n=0,1,,N.p(n) = \frac{n}{N}, \quad n = 0, 1, \dots, N.

(If you are interested in working out the solution and the general case when the coin can be biased, check out this lecture from Harvard's Statistics course.)

If you are curious, I simulated 1000010 000 trajectories and overlaid them on top of each other, with low opacity. (The paler a line is, the fewer trajectories go through it.) You can see here that starting from $1\$1, losing is much more frequent than winning.


Even though the game is fair (since winning or losing a round is equally probable), deeper pockets are advantageous. In real casinos, your account is tiny compared to theirs. Thus, in the long run, you are likely to lose.

Thus, the house (almost) always wins.

The truth is, casino games are never balanced. They are designed with probabilities that favor the house, so your chances are even worse than this simple mathematical model shows.

TL;DR: you don't stand a chance against a casino.

Having a deep understanding of math will make you a better engineer.

I want to help you with this, so I am writing a comprehensive book that takes you from high school math to the advanced stuff.
Join me on this journey and let's do this together!