I. Introduction

The gamblers ruin problem is a very famous problem in probability theory, with the first version dating back all the way to 1656 (per Wikipedia). In the modern form of the problem, a gambler starts off with some fortune and decides to try his luck (say, at a casino). He plays a game where he has a constant probability (say p) of winning each time he plays (since we’re more concerned with the probabilistic process than the specifics of the game, we might as well think of him as tossing a coin with p being the probability of seeing heads), typically winning 1$ if he wins the game and losing 1$ otherwise. Any time his total fortune crosses some upper bound (his target) or lower bound (his bank balance or 0 depending on the formulation), the game stops. The problem has many un-intuitive and interesting results. For example, that even if the gambler became infinitely wealthy and intends on continuing to play until he reaches his target, there is a finite probability he will never reach it if p < 0.5. No one seems however, to have pitted such wealthy gamblers against each other in a race. The question now changes from whether or not the gamblers will reach their target to which of them will do so first.

The answer of course, depends on the probabilities each one will win any one of the games they play until reaching their targets. The result is especially beautiful when both of them are tossing fair coins (p1 = p2 = 1/2 ). When evaluating the probabilities for these kinds of games, pi unexpectedly pops up in the result. And since we can devise races where we know the result in advance, we can use the result to find pi itself to arbitrary precision. What we get is a method for calculating pi that not only has a nice interpretation in terms of such games, but is also reasonably efficient at converging to pi.

II. Single wealthy gambler

Before we can consider a race of two wealthy gamblers, we need to analyze the probabilistic process describing the game for one of them (the single in the title means singular, not unmarried). As mentioned, the case of the single gambler is a well known problem and has been well studied. In this section, we review some important results, particularly in the limit of the gamblers wealth becoming infinitely large. These results are an important building block towards understanding how the races might play out.

First, we refer the reader to equation (4.14) of [1] where the gambler starts with i$ and his target is N$. The probability that he will reach his target before he reaches 0$ is then given by (where q = 1-p):

We formulate the problem in a slightly different way, defining the state as his profit instead of the total fortune. In this formulation, he starts with 0$, has a bank balance of b$ and a target of k$. to get the corresponding probability in this formulation, we replace i by b and N by k + b, giving us (starting with a profit 0$, probability he will reach target k$):

This is an important result which some people find unintuitive. Even an infinitely wealthy gambler, who is determined to keep playing until he reaches his target k, is only guaranteed to eventually get there if the odds are stacked in his favor or evenly (probability of winning each game p ≥ 1/2). Otherwise, there is a non-zero probability he will keep playing ad-infinitum, never reaching his target. Another thing worth noting is that:

and this makes intuitive sense, since for the gambler to increase his profit by k$, he has to repeat the feat of increasing it by 1$ k times. These properties of equation (2) will be used extensively in the rest of the paper. Another concept for the process defining the gamblers profit that will be crucial in analyzing gambler races is the stopping time of the wealthy gambler (after how many tosses does he reach his target and stop playing). We define and study this quantity in detail in the next section.

A. Stopping times

By now you know that we’re interested primarily in wealthy gamblers. These cartoons don’t care about how negative their profit goes since they have infinite finances. They care only about hitting their targets (k$). A natural question to ask then, is how many games (tosses) they will need to do this. What will that sweet toss be when they reach their goal. Since they stop playing the game only when they reach their goal, we can call this toss the ‘stopping time’ of the stochastic process defining the wealthy gamblers’ profit. Note that these stopping times have a strange characteristic. They have the same parity (state of being even or odd) as the gamblers target, k. To see this, assume the gambler is targeting k$ and gets t tails along the way. At his stopping time, his profit must be k$ by definition and so, he must have tossed t+k heads. So, the total number of tosses will be 2t + k.

It is obvious first that we must have t ≥ 0 since it is defined as the number of tails the gambler tossed. This means trivially that he if k is even, he can reach his target only on tosses that are even integers greater than or equal to k and if it’s odd, on odd integers that are greater than or equal to it. To avoid having to deal with stopping times that can only be even or odd, we define it as the number of tails (T_k) the wealthy gambler gets before reaching his target, k for the first time (since he stops as soon as he reaches it, this only happens once). We define the probability mass function (PMF) of T_k (denoted P(T_k = t) = h_k(t)) as the probability that when he reaches his target k for the first time, he has tossed t tails (automatically implying he tossed t + k heads for a total of 2t+k tosses). A first step towards calculating this probability is to count the number of ways in which he can get from 0$ in 0 tosses when he starts the game to k$ in 2t + k tosses when he finishes it. Let’s call this f(k, t). If we knew f(k, t) we could say:

Say, his fortune at any given toss is κ (which can be any integer). In order for him to get from toss 0 and fortune κ= 0 when he begins the game to toss 2t + k and fortune κ= k when he ends it, our wealthy gambler needs t tails and t+k heads as mentioned before. So, if we were simply counting the total paths, it would suffice to choose t out of the 2t + k tosses for tails, making the count of the paths:

Now, some of these paths however should be excluded from f(k, t) since they cross the κ= k line before toss 2t+k. And this is at odds with the requirement that he reach the target k for the first time on toss 2t+k. If he reaches k on any toss before toss 2t + k, then we can’t consider that a valid path as he would have stopped the game before toss 2t+k, making the statement that he stopped on 2t+k false.

Figure 1. Wealthy gamblers grid. The x and y axes are his toss number and profit. The purple line is his target, k and the grey grid contains all possible paths to that target. In this case, k = 3 and t = 2.

In figure 1, we should only consider paths that reach the green point without touching the purple line before doing so for f(k, t).

Let’s start with the simple case, k = 1. This means counting the ways f(1, t) to get to κ= 1$ on toss 2t + 1. Note that if you’re at κ= 0$ on toss 2t, then there is just one way to get to κ= 1$ on toss 2t + 1. So, if we know the number of ways to be at κ= 0$ on toss 2t without ever touching 1$ before that, it’s equivalent to f(1,t). Also note that whenever we touch 1$, we must have crossed 0$. Hence, f(1,t) is the number of ways of getting t tails and t heads in such a way that the cumulative number of tails is always greater than or equal to the cumulative number of heads. But this is equivalent to the count of Dyck words (words formed using two characters in equal quantities such that the cumulative count for the first character stays greater than or equal to the cumulative count of the second). This combinatorial object is basically the ‘Catalan numbers’. There is an excellent Wikipedia article on them with many proofs that the number of such paths is given by

Plugging this into (3), we get:

Eq (4)

We can’t quite call the expression in equation (4) the probability mass function (PMF) of the stopping time for a wealthy gambler targeting 1$ when p < 1/2 . This is due to equation (2) which indicates that the gambler will never reach his target with a probability (p/1-p) in this case. So we should have:

Now, to get h_k(t), we can conclude also from (2) that:

If we restrict ourselves to the scenario p < 1/2 we get from the above two equations,

Eq (5)

And this makes sense since in order for the wealthy gambler to ever reach k$, he has to perform the feat of increasing his fortune by 1$ k times in a row.

We now make use of the following remarkable identity from [2]; a modification of equation (5.68), renaming some variables and noticing that:

Leads us to:

Eq (6)

First of all, note how surprising it is that k simply floats in from the power of the summation on the left hand side to inside the summation on the right hand side, seeming to replace the 1’s in the process. You can see a proof of this in the answer on the Q&A website ‘Math Overflow’ [22]. It was also proven using generating functions by Rob Johnson in [24].

Second, if we replace z in equation (6) by p(1 -p), multiply by pk on both sides and compare with (5) it is easy to conclude that:

Eq (7)

and,

Eq (8)

It is also possible to modify any of the proofs in the Wikipedia article on Catalan numbers linked earlier (which apply specifically to f(1, t), the special case when k = 1) to produce the result in equation (7). My favorite is Andre’s reflection method.

B. Survival function for stopping times

Just as we defined and calculated the probability mass function for the stopping time, T_k (h_k(t) = P(T_k = t)) in the previous section, we define and calculate its survival function in this section H_k(t) = P(T_k > t). We can say by definition,

Eq (9)

It seems there isn’t an easy way to get a nice, closed form expression for this summation (indeed, none might exist). However, for the special case where p = 1/2 , making the process a Martingale, there is a way to directly get an expression for it.

Let’s first consider P(T_k ≤ t). This means we have two boundaries, hitting either of which causes our process to stop. The first is the old vertical boundary (parallel to the x-axis at k), which is the wealthy gambler’s target. The second is the horizontal boundary at t (parallel to the y-axis).

Let’s define τ as the time until our wealthy gamblers process hits any of these boundaries and W_τ as his profit when he hits any of them. Also, let W_{2t+k} be his fortune at step 2t + k if he had just continued playing indefinitely.

Since the only way the process can stop on or before 2t+k is if the gambler ‘prematurely’ reaches k we can say:

If we know that W_τ = k, it means we know that the wealthy gamblers fortune was k at some point before toss 2t + k. Given this information, the probability he’ll end up with a fortune higher than k or lower than k at t should be the same by symmetry (since that the probabilities of winning and losing each game are the same).

This makes the last two terms of the previous expression equal

So we get,

Eq (10)

Now, if W_{2t+k} > k it means the profit was more than k at toss 2t+k. So, the fact that the process stopped because the profit hit k at some previous point is a trivial consequence, its probability encompassed by the first event. So we can say,

Eq (11)

Now, recall that t is the number of tails required for the wealthy gambler to be at k$ on toss 2t + k. If he gets a different number of tails (say r), his fortune will be different from k. It’s very easy to see that the probabilities of getting r tails by toss 2t + k is binomial (2t + k total tosses, r are tails and the rest are heads; so we choose which r should be tails). Here, r can be any integer from 0 to 2t+k. Given this, we get the probability of getting r tails by toss 2t+k:

But as mentioned, we’re only interested in the special case where p = 1/2 . Here we get,

and,

This leads us to:

From the preceding , we end up with the important result

that when p = 1/2 :

Eq (12)

IV. LET THE RACES BEGIN

Now we have all the expressions we’ll need for the stopping time of these wealthy gamblers to pit them against each other in races (at least when p = 1/2 which we’ll assume unless stated otherwise from here on out). Let’s define terminology before we dive in. Let’s say we have two wealthy gamblers, one targeting k_1$ and the other targeting k_2$ where k_1, k_2 ∈ Z.

w_t(k_1, k_2) will be the probability the one targeting k_1 beats the one targeting k_2 at the toss where the k_1 targeting wealthy gambler has t tails.

will be the probability that the one targeting k_1$ beats the second one on or before the toss where the k_1 targeting wealthy gambler has s tails (which is 2s + k_1).

3.

will be the probability that the one targeting k1$ wins at all in any number of tosses.

4.

will be the probability that the one targeting k_1 draws (reaches his target at the same toss as) with the one targeting k_2 on or before the toss where the former has t tails.

5.

will be the probability that the one targeting k1 draws (reaches his target at the same toss as) with the one targeting k2 period. Unlike W(k_1, k_2), D(k_1, k_2) is commutative meaning we can flip the arguments and get the same result.

A. A simple start

Let’s start with the simplest possible race that isn’t trivial. Our first wealthy contestant targets 1$ and the second one targets 2$. The probability that the second wealthy gambler reaches 2$ on toss 2t + 2 is given by h_2(t) while the probability that the first wealthy gambler will reach the target after toss 2t+1 is given by H_1(t). Note that it is impossible for the 1$ targeting gambler to reach his target on toss 2t+2. So, after 2t + 1 means 2t + 3 onwards. Multiplying these two probabilities captures the probability of the event where the 2$ targeting gambler defeats the 1$ targeting gambler at the toss where he has accumulated t tails (which would mean toss 2t + 2). Let’s call this probability w_t(2, 1). So, we get:

Eq (13)

Now, the events modeled by w_t(2, 1) are mutually exclusive. So, the probability that the 2$ targeting gambler will defeat the 1$ targeting gambler in any number of tosses becomes:

Eq (14)

Using equation (8) we have:

And using equation (12):

Plugging these into equation (14) we get,

Eq (15)

This series is linked very closely to a Ramanujan-Sato series that involves Catalan numbers. The Wikipedia article on the topic has a whole list of identities (courtesy R. Steiner) involving such series and the last one in that list can be expressed as:

Eq (16)

If we accept equation (16) (we will prove it in the next section), it is not hard to calculate W(2, 1) as defined in equation (15).

Replacing t by t + 1 so we can re-index to start at 0:

Eq (17)

Eq (18)

Where in equation (17) we used the binomial identity:

So, using equations (18) and (16) we get:

Eq (19)

Numerically, this is W(2, 1) ~0:2732, which passes the basic sanity check that it should have been less than 0.5 (since the 2$ targeting gambler is obviously at a disadvantage compared to his 1$ targeting competitor). But the expression we get is fascinating since it involves π. And it turns out that any such race between two wealthy gamblers we can envision seems to share this property no matter what their targets (as long as the coins they are tossing are fair). In the table below are some examples of such races. The entry in the (i, j) position of the table is the probability that a wealthy gambler targeting i$ will reach his target before a wealthy gambler targeting j$. Note that the diagonals are not zero due to the possibility of draws.

In fact, if we construct a race where we know the answer in advance, we can use it to calculate π itself as we will see in section V.

B. Generalized race expression

In this sub-section, we will extend the method used to calculate W_t(2, 1) to general wealthy gambler races. Let’s say the two wealthy gamblers are targeting k_1$ and k_2$. Let’s first obtain an expression for the first one beating the second one in a race. Let’s look at things from the perspective of the first wealthy gambler and look at the independent events where he wins at the toss where he has t tails (so, t+k_1 heads and 2t + k_1 total tosses). First, he must reach his target at this particular toss. But we also have to ensure that the second wealthy gambler doesn’t reach his target on the same toss or before toss 2t+k_1. Since we’ve been expressing the tosses in terms of the number of tails each of the wealthy gamblers get, we need to ask how many tails are permissible for the second wealthy gambler. Also, since we need to compare the two of them, it makes our life easier if we ask ‘how many more tails the second wealthy gambler is permitted to have than the first’. Keeping this in mind, let’s assume that the number of tails for the second wealthy gambler is t+x. Taking a cue from equation (13), for each t we will multiply the probabilities that the first wealthy gambler reaches his target with exactly t tails h_k_1 (t) = P(T_k_1 = t) and the probability that the second one reaches his target strictly after toss 2(t+x)+k_1. Since the survival function, H_k_2 (t) the way we defined it in (9) already accounts for the ‘strictly after’ part, we just need to ensure that the toss we plug into it should be greater than or equal to the toss at which the first one is reaching his target. So we get,

Now, x must obviously be an integer so the equation above suggests that it will be the greatest integer less than or equal to (k_1-k_2)/2. This is generally denoted by [.] allowing us to write:

Putting all of this together, we can get the general probability that the wealthy gambler targeting k_1$ will beat the one targeting k_2$ by the time he has s tails.

Eq (20)

We can similarly reason about the draw probabilitities. But we need to keep in mind that a draw is possible only when k_1 and k_2 are both even or both odd. So, k_1- k_2 must be even meaning that (k_1-k_2)/2 ∈Z. So, we don’t need the greatest integer function anymore.

Of course, as we let s → ∞ in the equations above, we get W(k_1, k_2) and D(k_1, k_2), the probabilities that these events will happen period.

V) Why π

In this section, we will try and understand why the solutions to all these gambler races involve π. We do this by first mechanically computing the summation in equation (16). Then, we will try and provide some intuition for where the π’s are coming from.

To evaluate the infinite summation describing W(2, 1) given by equation (15), we try and evaluate the partial summation first. This means that instead of summing all the way to 1, we sum only to s. Let’s call this partial summation, W_s(2, 1) and using the arguments of the previous section, we can interpret it as the probability the 2$ targeting gambler will beat the 1$ targeting gambler by the toss where he would accumulate s tails, toss number 2s + 2.

Note the following identity for wt(2; 1), which can be easily verified by expanding the binomial terms:

This enables us to write:

where

Then we can say,

plugging in U(s) the way we defined it we get,

Eq (23)

Let’s now derive the following identity that connects large binomial terms like U(s) to π:

Eq (24)

Where i, j and l are much smaller than s. In the following, we will use Stirling’s approximation for factorials:

Here, u = i -j. Making use of the fact that s is much larger than i, j, l and u and canceling terms we get,

Using equations (24) and (23) we get equation (19):

This exercise gives us some rough intuition for where the 1/π term comes from in these expressions. Admittedly, the discussion that follows is somewhat loose and it would be nice to have a more rigorous connection with π and circles, but this is what we have so far.

From equations (8) and (12), we see the expressions for individual wealthy gamblers involve binomial coefficients close to their mode (which is a feature of Catalan numbers in general).

The probabilities we’re after (one of the gamblers beating the other) involve two of these binomial terms close to their mode multiplied over all possible t up to s. These summations tend to produce expressions that also involve squares of binomial terms close to the mode (along with some polynomial terms on the side), this time involving s.

However, as s becomes large (and since the races we’re considering have p = 1/2 , ensuring symmetry around the mode), this binomial term starts to resemble a Gaussian (central limit theorem). And we know that the Gaussian around it’s mode has a PDF with a (1/π)^.5 term. So, squaring yields a 1/π term.

VI. WEALTHY GAMBLER DRAW PROBABILITIES FOR THE π

In this section, we try and leverage the special structure (a+b/ π) of the expressions describing the probabilities of various results relating to these wealthy gambler races to get π itself. For this, we need to construct a race where we already know the answer, so we can work backwards to get π.

The most obvious and simple way to do this is to consider draws. A draw is defined as the event where the two wealthy gamblers reach their targets on the same toss. As mentioned before, this is only possible if the parities of the targets for the two wealthy gamblers are the same. But let’s simplify things even further and give the two gamblers the same target, k. Now it is logical that as k becomes large, it’s going to become increasingly unlikely that the two gamblers are going to reach their targets at exactly the same time. So, if we knew the probability of a draw, D_k (in terms of the (a+b/ π) structure) as a function of k, we could make k very large, set D_k to 0 and then use the a and b to calculate the value of π.

We know that equation (8) gives us the probability that any one of the wealthy gamblers will be at k$ on toss 2t+k. If both of them are to reach k$ on toss 2t+k we can simply square this probability. And to get the overall probability of a draw, we sum over all possible values of t.

Eq (25)

It isn’t easy to find a general expression for the summation above, but we can use Mathematica to get the first few terms (and eventually get the next best thing, a recurrence).

We can see that the following expression for D_k seems to hold in general:

Eq (26)

We see that the sequence Gk is given by: 1; 5; 25; 129; ….

Searching for this on OEIS yields the sequence A002002. Using the fact that this sequence satisfies the recurrence:

In [25], Anders Kaseorg found a similar recurrence for D_k.

Eq (27)

Although we don’t have a proof for (27) above, we did verify it for hundreds of terms, so it is quite unlikely it isn’t true. And starting with the first three terms for D_k, we can go to arbitrarily large values of k by successive computation.

Now, we know that D_k must start approaching 0 as k becomes large. So, our general algorithm for calculating π is to set D_k = 0. Then we can use equation (26) to get the approximation of π from setting D_k = 0:

Using the expressions for D_1 to D_12 provided above we get:

Note that the true value of π to 15 decimal places is:

π = 3.141592653589793

So, we seem to be at 9 decimal places of accuracy by D_12 and are gaining about one decimal place as we increase k by 1. Admittedly, this method is probably not going to set records for accurate digits of π as it stands. However, there is scope for improving it since we know D_k is always slightly greater than 0, meaning out estimates are always upper bounds. Also, this method provides an infinite series with a nice interpretation in terms of wealthy gambler races.

REFERENCES

[1] Sheldon Ross, Introduction to Probability Models, Elsevier, 1970.

[2] Ronald L. Graham and Donald E. Knuth and Oren Patashnik, Concrete

Mathematics, Addison Wesley, 1994.

[3] Richard S. Sutton and Andrew G. Barto, Reinforcement Learning: An

Introduction, The MIT Press, 2017.

[4] William Feller, An Introduction to Probability Theory and Its Applications,

John Wiley & Sons, 1968.

[5] Mogens Esrom Larsen, Summa Summarum, 2006.

[6] Richard P. Stanley, Enumerative Combinatorics, 2011.

[7] Igor Pak, History of Catalan numbers, available at https://arxiv:org/

pdf/1408.5711.pdf.

[8] Singh Samir, Application of Z-transform on gambler’s ruin in probability

theory and other results (2017), available at https://ijasre.net/

uploads/1/3357.pdf.

[9] Khoshnevisan Ethier, Bounds on gambler’s ruin probabilities in terms

of moments (2001), available at https://pdfs.semanticscholar.org/6c2a/

52faa10e098d94f8066d7f4c05af65743e62.pdf.

[10] Robert L. Wolpert, Introduction to Martingales (2010), available at

http://www2.stat.duke.edu/courses/Fall10/sta205/lec/topics/mg.pdf.

[11] Nic Freeman, Martingale Theory and Applications (2015), available at

https://people.maths.bris.ac.uk/mabat/MARTINGALE THEORY

2016/NIC FREEMAN notes.pdf.

[12] E. Catalan, Note sur une E´quation aux differe´nces finies (1838).

[13] Peter Hinton and Jean Pederson, Catalan Numbers, their Generalization,

and their uses (1991).

[14] Reza Kahkeshani, A generalization of the Catalan Numbers (2013),

available at https://cs.uwaterloo.ca/journals/JIS/VOL16/Kahkeshani/

kahke3.pdf.

[15] D. Merlini and R. Sprugnoli and M. C. Verri, Lagrange Inversion:

when and how (2006).

[16] Ira M. Gressel, Lagrange Inversion (2016), available at https://

arxiv:org/abs/1609:05988.

[17] Gert Almkvist and Jes´us Guillera, Ramanujan-Sato-Like Series

(2013), available at https://pdfs:semanticscholar:org/5ed8/

3ed180b5e6d374a4c5370dffff5022bec53e:pdf.

[18] D.H Bailey and J.M. Borwein and P.B. Borwein and S. Plouffe, The

Quest for Pi (1997), available at https://link:springer:com/content/pdf/

10:1007/BF03024340:pdf.

[19] Nayandeep Deka Baruah and Bruce C. Berndt and and Heng Huat

Chan, Ramanujan’s Series for 1

: A Survey (2009), available at https:

//faculty:math:illinois:edu/berndt/articles/monthly567–587:pdf.

[20] Srinivas Ramanujan, Modular equations and approximations to

(1914), available at http://ramanujan:sirinudi:org/Volumes/published/

ram06:pdf.

[21] Pawel Lorek and Piotr Markowski, Conditional Gambler’s ruin problem

with arbitrary winning and losing probabilities (2018), available

at https://arxiv:org/pdf/1812:00687:pdf.

[22] Markus Scheuer (https://math.stackexchange.com/users/132007/markusscheuer),

Proof of identity about generalized binomial

sequences., Mathematics Stack Exchange. URL:

https://math.stackexchange.com/q/3064511 (version: 2019–01–13).

[23] Markus Scheuer, Race of the wealthy gamblers — How do

I get this closed form?, Mathematics Stack Exchange. URL:

https://math.stackexchange.com/q/3054440 (version: 2018–12–29).

[24] Rob Johnson (https://math.stackexchange.com/users/13854/robjohn),

Probability that random walk will reach state k for the

first time on step n, Mathematics Stack Exchange. URL:

https://math.stackexchange.com/q/3080714 (version: 2019–01–21).

[25] Anders Kaseorg (https://math.stackexchange.com/users/38671/anderskaseorg),

Using a gamblers race to approximate , Mathematics Stack

Exchange. URL: https://math.stackexchange.com/q/3072016 (version:

2019–01–13).