Can a wealthy gambler get ruined?

Rohit Pandey
6 min readJan 13, 2019

--

1. The wealthy gamblers ruin problem

We discuss here a probabilistic process that plays out frequently across the world. A gambler feeling lucky, goes to a casino with some money in his pocket. He then starts compulsively playing some game (betting some amount each time he plays) he likes/ thinks he is good at in the hope of becoming rich. Since he has a bit of a gambling habit, the only way he will stop gambling is once he runs out of money in his wallet. Since he has this obsessive habit, the common lesson goes that he will always lose all his money since he is playing against an almost infinitely rich casino. The gambler is thus doomed to eventually hand over his money to the people running the casino.

However, what if we even the odds a little and make our gambler infinitely rich as well? Also, let’s add a bit of discipline to him as well and give him a target (say k$). Once he reaches this target, the gambler decides to quit while the going is good and goes home with his winnings.

Surely, now the gambler should reach his target eventually since by definition, he keeps playing until he does and he can play for as long as he wishes.

Well, the answer is that it depends (which some people find surprising). And we will pick apart this nuance in this blog.

2. Empirical observation for non-wealthy gamblers with code

In this section, we will formulate this process with Markov chains. This means defining a state space for the gambler. Here, we know there is always a number attached to the gambler at any given time. And that number is his total profit up to that point. When he first arrives at the casino, his total profit is 0$ since he hasn’t played. And when he reaches the profit he’s targeting (k), he leaves. So, we can think of the profit as a state he is in.

Also, he could be playing any game at the casino, but at the end of the day, there is some probability he will win the game (say p) in which case the probability he will lose is (1−p). We might as well think of these as coin flips. To keep things simple, let’s say he bets a constant amount of 1$ every time he plays.

2.1. Forming the Markov transition matrix

Now, the number of possible states our gambler can be in is infinite (he could get a thousand tails in a row for instance and then his state would be −1000). So, to simplify things let’s make his state space finite for now by assuming he has a certain bank balance (say b $). Also, recall that his target is k $. So, now the possible states he can be in range from −b to k (he stops playing and goes home if he either spends his entire bank balance, b or reaches his target, k). To make things concrete, let’s say b=3 and k=2.

It is clear that his total winnings can be in one of the following states: [-3, -2, -1, 0, 1, 2]. Also, when he starts the game in state 0, he goes to state 1 with a probability p and -1 with probability 1−p. And if he’s in any state (n) apart from the two absorbing states (−b and k), he goes to state n+1 with probability p and n−1 with probability 1−p.

We can express his probabilities of jumping from one state to another in a matrix.

Transition probability matrix for the gambler

Now, if we can find the probabilities that the game ends in each of the absorbing states (−b and k), we can use those to find the probability the gambler will win. Then to see what happens as the gambler becomes wealthy, we can slowly increase his bank balance b.

2.2. Using the transition probability matrix to find the probability the gambler will win

Notice that the gamblers Markov chain described in the previous section involved two kinds of states. There were terminal states (a.k.a. “absorbing” a.k.a. “recurrent”), entering into which causes the game to immediately stop. These are −b (going bankrupt) and k (reaching his target). And then all the states in between those two are non-terminal (a.k.a. “transient”) meaning that entering them does not cause the game to stop and the gambler will play another turn. We know that in the long run, the game is going to stop and so, the gambler is going to find himself in one of the two recurrent states. Many Markov chains (not just the ones corresponding to gamblers) have these two kinds of states. And all of them end up in one of the recurrent states (note that once the chain enters a recurrent state, it stays there; so the row in the transition matrix will have zeros corresponding to all other states and a one where the row crosses the main diagonal).

The natural question is always, what are the probabilities of the chain ending up in each of the recurrent states? Here, we provide a general method to answer that question given the transition matrix.

First, let’s re-arrange the columns and rows of the matrix in the previous section so that all the recurrent states are at the end.

Transition matrix re-arranged.

The bottom two rows (corresponding to the two recurrent states) seem quite redundant. The interesting parts of this matrix are the transitions from transient states to other transient states (marked Q in the figure above) and the ones from transient to recurrent (marked R).

Given that we start in transient state i, the probabilities that the game ends up in each of the absorbing states is given by the ith row of the matrix:

Eq (1)

To see the reason, condition the absorption process from state i to state j based on what happens in the first transition: either the absorption happens in the first transition with probability R_ij, or a transition occurs into some other transient state k with probability Q_ik and from there transitions until eventually absorbed with probability u_kj. This can be expressed as the matrix equation:

where solving for u generates equation (1) above.

Here is a python method that constructs the matrix for a gamblers process and solves the equation given above (dependency, only numpy).

The method allows us to enter a bank balance, target and probability of winning each game (p). It demonstrates that when p≥0.5, the wealthy gambler (large b) will always reach his target if he keeps playing. However, as soon as p drops below 0.5, even slightly, the probability that he will never reach his target becomes finite even for an infinitely wealthy gambler.

You can play with the code to see this. However, we can demonstrate this mathematically as well and calculate in closed form the probability that he will ever reach his target. Stay tuned for another blog on that.

--

--

Rohit Pandey

I like to explain data science concepts through words, visualizations and code in the hope one of them will click. For my day job, I work at Microsoft Azure.