# Gambler's Ruin - Probability of Losing in t Steps

I would be surprised if this hasn't been asked before, but I cannot find it anywhere.

Suppose we're given an instance of the gambler's ruin problem where the gambler starts off with $i$ dollars and at every step she wins 1 dollar with probability $p$ and loses a dollar with probability $q = 1 - p$. The gambler stops when she has lost all her money, or when she has $n$ dollars. I am interested in the probability that the gambler loses in $t$ steps.

I know how to find the expected number of steps before reaching either absorbing state, and how to solve the probability that she loses before winning $n$ dollars, but this one is eluding me. Let $P_{i, t}$ be the probability that the gambler goes broke in $t$ steps given that she started with $i$ dollars. I have set up the recurrence: $$P_{i, t} = qP_{i-1, t-1} + pP_{i+1, t-1}$$ and we know that $P_{0, j} = 1$ and $P_{n, j} = 0$for all $j$, and $P_{i, 0} = 0$ for all $i > 0$. I'm struggling to solve this two dimensional recurrence.

If it turns out to be too hard to give closed form solutions for this, can we give tighter bounds than just the probability that the gambler ever loses?

Since my previous post has been deleted, I have no chance to show the detail of my knowledge in this problem. I decided to re-post what I knew here if the editors think it is appropriate.

This topic is under the "Complements and Details" of Chapter One on the book "Probability theory I" 4th edition written by Dr. M. Loeve on page 48. And I quote the solution as follows.

The gambler has $$x$$ dollars and wins or loses one dollar with respective probabilities $$p$$ and $$q = 1-p$$. Find the probability $$P_{x,n}$$ of his ruin at the $$n$$-th game, that is, starting at $$x$$ with $$0 < x < a$$ to arrive at $$y \leq 0$$ before reaching $$y \geq a$$. $$\begin{equation*} P_{x,n+1} = pP_{x+1,n} + qP_{x-1,n} \end{equation*}$$ with $$P_{0,a} = P_{a,n} = 0$$ and $$P_{0,0} = 1$$, $$P_{x,0} = 0$$. The solution is $$\begin{equation*} P_{x,n} = a^{-1}2^{n}p^{(n-x)/2}q^{(n+x)/2} \sum_{k=1}^{a-1} \cos^{n-1}\frac{\pi k}{a}\sin \frac{\pi k}{a}\sin \frac{\pi kx}{a} \end{equation*}$$ Dr. M. Loeve only provided his solution without any derivation.

• In this solution, putting $x=0,n=0$ in $P_{x,n}$, we get $P_{0,0}=0$, as $\sin\frac{\pi kx}{a}=0 \ \forall 1\le k\le a-1$ when $x=0$. But this violates the boundary condition. Sep 6, 2022 at 13:50
• @HackR $a$ should be at least $1$, and if $a = 0$, we cannot simply say sin(\pi k x/a) is zero because the denominator is also zero. Sep 7, 2022 at 0:00
• I only put particular values of $x$ and $n$ to get to the conclusion. The value of $a$ does not matter as long as it is greater than 0. Sep 7, 2022 at 1:28
• @HackR Sorry for my careless, but still we cannot put the conclusion based on your saying, since, e.g., if $a = 2$, we have, in the summation, $\tan \frac{\pi}{2} \times \sin \frac{\pi kx}{2}$, as $x$ approaches $0$. It is $\infty \times 0$ type and not simply equals to $0$ Sep 7, 2022 at 2:02

I do not know if I misinterpret your question, but I think the probability of going to ruin in $$t$$ steps is just the probability of losing $$i$$ times more than winning. Let $$m$$ be the number of wins, and $$n$$ be the number of losses, so obviously $$m+n=t$$

To lose means $$n=m+i$$, so $$n=\frac{t-i}{2}$$ and $$m=\frac{t-3i}{2}$$

$$p_0(t) = p^{\frac{t-3i}{2}}\cdot q^{\frac{t-i}{2}}$$

or if you mean "losing in $$\leq t$$ steps", this would change of course to

$$P_0(\leq t) = \sum_{k=i}^{t} p_0(k)$$

• Hi, do we need to consider which state go back and which go forward? Jun 1, 2018 at 9:01
• I think when I asked this question I would have been satisfied with answering either exactly t steps or at most t steps. Either way, your solution seems to lose part of the nuance of the question. There are lots of invalid walks that are captured by "losing i times more than winning" such as walks which have the gambler going into negative money, or reaching n dollars and continuing to play. Jun 8, 2018 at 23:47

The first (edited) answer is the correct probability for reaching 0 Dollars at exactly step t. That is an incorrect definition of ruin as @Andrew S points out.

It is not the probability of reaching 0 Dollars for the first time without having previously reached n Dollars, during t steps or fewer steps if 0 or n Dollars is reached earlier, which is the correct definition of ruin.

This is a tough problem. I do not know of a closed solution...only a closed approximation and a path-counting summing algorithm which counts and sums only the permitted paths from i Dollars to 0 Dollars for each step from 1 to t.

• I'll settle for a closed approximation if you have it. Jan 18, 2019 at 3:32