The gambler’s ruin problem is often applied to gamblers with finite wealth playing against a bookie or casino assumed to have a much larger amount of wealth available, in principle infinite. It can then be proven that the probability of the gambler’s eventual ruin tends to 1 even in the scenario where the game is fair.
Author
Angelo Maria Sabatini
Published
May 5, 2024
Problem
The gambler’s ruin problem, first mentioned by Blaise Pascal in one of his letters to Pierre Fermat, was then reformulated by Christiaan Huygens, leading to important advances in the mathematical theory of probability. The statement of the problem considered here is slightly different from the one described by either Pascal or Huygens (Bertsekas and Tsitsiklis 2008).
Consider a gambler who starts with an initial wealth of €\(k\) and then on each successive bet either wins €1 or loses €1 with probabilities \(p\) and \(q=1−p\) respectively. Different bets are assumed independent. The gambler’s objective is to reach a total wealth of €\(n\) (\(n>k\)). If the gambler succeeds, then the gambler is said to win the game. The gambler stops playing after winning or getting ruined (running out of money), whichever happens first.
Calculate the probability that the gambler wins. In particular, which is the probability of the gambler becoming infinitely rich?
Solution
Let us denote by \(A\) the event that the gambler ends up with €\(n\) and by \(F\) the event that the gambler wins the first bet. The probability of the event \(A\) given that the gambler starts with €\(k\) is written \(w_k\). The total probability law allows us to write:
where \(\overline{F}\) is the complement of \(F\), namely the event \(\overline{F}\) is that the gambler loses the first bet.
Now, the event \(A\,\vert\,F\) is the event \(A\) given that the gambler starts with €\((k+1)\), whose probability is \(w_{k+1}\) (because of the independence from the past). The event \(A\,\vert\,\overline{F}\) is the event \(A\) given that the gambler starts with €\((k-1)\), whose probability is \(w_{k-1}\) (because of the independence from the past). Equation 1 reads:
To interpret the meaning of Equation 6, suppose that the gambler starting with an initial wealth of €\(k\) wishes to continue gambling, with the intention of earning as much money as possible. So there is no winning value €\(n\): the gambler will only stop if ruined. If \(p>1/2\) (each gamble is in favor of the gambler), then there is a positive probability that the gambler will never get ruined but instead will become infinitely rich. Conversely, if \(p\leq0.5\) (each gamble is not in favor of the gambler), then the gambler will get ruined with probability one.
Markov chain model
The discrete-state discrete-time Markov chain show in Figure 1 can be proposed to model the gambler process (Bertsekas and Tsitsiklis 2008). The \(n+1\) states, numbered from 0 to \(n\), represent the gambler’s wealth at the start of each bet. The first state 0 corresponds to ruin (getting out of money), the last state \(n\) corresponds to win. Given the rules of the game, the states 0 and \(n\) are absorbing, in the sense that it is not possible to escape from each of them anymore, once they are entered. All the other states are transient.
Figure 1: Transition probability graph for the gambler’s ruin problem.
The problem is then to find the probabilities of absorption at each one of the two absorbing states. These absorption probabilities depend on the initial state \(k\;(0<k<n)\). It is worthy noting that the memoryless character of the process implies that, if the gambler happens to revisit the initial state \(k\) after a while, the absorption probabilities are the same they were initially.
Transition probability matrix
The state of a discrete-state discrete-time Markov chain is denoted by \(X_t\), that can change at certain discrete time instants \(n\). The state space of the chain is composed of a finite set \(\mathscr{S}=\{1,\cdots,m\}\). The Markov chain is described in terms of its transition probability \(p_{ij}\):
for all times \(t\), all states \(i,j\in\mathscr{S}\) and all possible sequences \(i_0,i_1,\cdots,i_{t-1}\) of earlier states. Thus, the probability law of the next state \(X_{t+1}\) depends on the past only through the value of the present state \(X_t\).
All of the elements of a Markov chain model can be encoded in a transition probability matrix, which is simply a two-dimensional array whose elements at the \(i\)th row and \(j\)th column is \(P_{ij}\):
Consider a Markov chain in which each state is either transient or absorbing. We fix a particular absorbing state \(s\). It is possible to show that the probabilities \(w_k\) of eventually reaching state \(s\), starting from \(k\), are the unique solution of the equations \(w_s=1, w_i=0\), for all absorbing \(i\neq s\), and for all transient \(i\):
\[
w_i=\sum_{j=1}^mp_{ij}w_j
\tag{10}\]
Example 1 (Gambler’s discrete-time Markov chain) For \(n=4,p,q=1-p\) the transition probability matrix of the gambler’s discrete-time Markov chain is given by:
The following code written in R simulates the gambler process (adapted from (Dobrow 2016)).
Code
set.seed(2001)gambler <-function(k, n, p) { stake <- kwhile (stake >0& stake < n) { bet <-sample(c(-1, 1), 1, prob =c(1-p, p)) stake <- stake + bet }if (stake == n) return(1) elsereturn(0)} k <-15# initial wealthn <-120# final wealthp <-0.5# probability of win at each betntrials <-1000# number of independent trialssim <-replicate(ntrials, gambler(k, n, p))p_ruin <-1-sum(sim)/ntrials
The probability of ruin estimated over 1000 iterations of the gambler process is 0.888, in close agreement with the value 0.875 computed from Equation 5.
It is noted that, at each time step, the gambler appears to move randomly, either to the left or to the right by a fixed unit distance with probability \(p\) and \(1-p\), respectively. The gambler undergoes a simple random walk in one dimension, whose state space is the set of the integers \(\mathbb{Z}\). The limitations to values of \(\mathbb{Z}\) between 0 (ruin) and \(n\) (win) are the consequence of the gambling rules: these rules settle two absorbing barriers to the motion of the random walker. Nine exemplary sample paths of the random walk are shown in Figure 2, for the case that \(k=30,n=120,p=0.5\).
Code
library(tidyverse)library(ggpubr)set.seed(2001)k <-30# initial wealthn <-120# final wealthp <-0.5# probability of win at each betntrials <-9# number of independent trialsnstep <-1000# number of stepstraj <-matrix(NA, nrow = nstep, ncol = ntrials)for (i in1:ntrials) { traj[1, i] <- k jmax <- nstepfor (j in2:nstep) { bet <-sample(c(-1, 1), 1, prob =c(1-p, p)) traj[j, i] <- traj[j-1, i] + betif (traj[j, i] ==0| traj[j, i] == n) {break } }} t <-rep(seq(0, nstep-1, by =1), ntrials)path <-rep(c("1", "2", "3", "4", "5", "6", "7", "8", "9"), each = nstep)traj <-c(traj)df <-data.frame(t = t, path = path, data = traj)my_theme =theme(axis.title.x =element_text(size =14),axis.text.x =element_text(size =12),axis.title.y =element_text(size =14),axis.text.y =element_text(size =12),legend.title =element_text(size =12),legend.text =element_text(size =12),panel.border =element_blank(),panel.grid.major =element_blank(),panel.grid.minor =element_blank(),panel.background =element_blank(),panel.spacing =unit(1, "lines"),axis.line =element_line(colour ="black"))ggplot(df, aes(x = t, y = data, path = path)) +geom_line() +labs(x ="bets",y ="gambler's wealth") +geom_hline(yintercept =0, linetype ="dashed") +geom_hline(yintercept =120, linetype ="dashed") +scale_y_continuous(breaks =c(0, 30, 60, 90, 120)) +facet_wrap(~path, labeller ="label_both") + my_theme
Figure 2: Gambler’s random walk: nine sample paths. The outcome of up to a maximum of 1000 bets is considered here.