# The gambler’s ruin problem

This post discusses the problem of the gambler’s ruin. We start with a simple illustration.

Two gamblers, A and B, are betting on the tosses of a fair coin. At the beginning of the game, player A has 1 coin and player B has 3 coins. So there are 4 coins between them. In each play of the game, a fair coin is tossed. If the result of the coin toss is head, player A collects 1 coin from player B. If the result of the coin toss is tail, player A pays player B 1 coin. The game continues until one of the players has all the coins (or one of the players loses all his/her coins). What is the probability that player A ends up with all the coins?

Intuitively, one might guess that player B is more likely to win all the coins since B begins the game with more coin. For example, player A in the example has only 1 coin to start. Thus there is a 50% chance that he/she will lose everything on the first toss. On the other hand, player B has a cushion since he/she can afford to lose some tosses at the beginning.

___________________________________________________________________________

Simulated Plays of the Game

One way to get a sense of the winning probability of a player is to play the game repeatedly. Rather than playing with real money, why not simulate a series of coin tosses using random numbers generated in a computer? For example, the function =RAND() in Excel generates random numbers between 0 and 1. If the number is less than 0.5, we take it as a tail (T). Otherwise it is a head (H). As we simulate the coin tosses, we add or subtract to each player’s account accordingly. If the coin toss is a T, we subtract 1 from A and add 1 to B. If the coin toss is an H, we add 1 to A and subtract 1 from B. Here’s a simulation of the game.

$\begin{array}{ccccccc} \text{Game} & \text{ } & \text{Coin Tosses} & \text{ } & \text{Coins of Player A} & \text{ } & \text{Coins of Player B} \\ \text{ } & \text{ } & \text{ } & \text{ } & \text{ } & \\ \text{ } & \text{ }& \text{ } & \text{ } & 1 & & 3 \\ 1 & \text{ }& H & \text{ } & 2 & & 2 \\ \text{ } & \text{ }& T & \text{ } & 1 & & 3 \\ \text{ } & \text{ }& H & \text{ } & 2 & & 2 \\ \text{ } & \text{ }& H & \text{ } & 3 & & 1 \\ \text{ } & \text{ }& H & \text{ } & 4 & & 0 \\ \end{array}$

In the first simulation, player A got lucky with 4 heads in 5 tosses. The following shows the next simulation.

$\begin{array}{ccccccc} \text{Game} & \text{ } & \text{Coin Tosses} & \text{ } & \text{Coins of Player A} & \text{ } & \text{Coins of Player B} \\ \text{ } & \text{ } & \text{ } & \text{ } & \text{ } & \\ \text{ } & \text{ }& \text{ } & \text{ } & 1 & & 3 \\ 2 & \text{ }& H & \text{ } & 2 & & 2 \\ \text{ } & \text{ }& H & \text{ } & 3 & & 1 \\ \text{ } & \text{ }& T & \text{ } & 2 & & 2 \\ \text{ } & \text{ }& H & \text{ } & 3 & & 1 \\ \text{ } & \text{ }& H & \text{ } & 4 & & 0 \\ \end{array}$

Player A seems to be on a roll. Here’s the results of the next two simulated games.

$\begin{array}{ccccccc} \text{Game} & \text{ } & \text{Coin Tosses} & \text{ } & \text{Coins of Player A} & \text{ } & \text{Coins of Player B} \\ \text{ } & \text{ } & \text{ } & \text{ } & \text{ } & \\ \text{ } & \text{ }& \text{ } & \text{ } & 1 & & 3 \\ 3 & \text{ }& T & \text{ } & 0 & & 4 \\ \text{ } & \text{ } & \text{ } & \text{ } & \text{ } & \\ \text{ } & \text{ }& \text{ } & \text{ } & 1 & & 3 \\ 4 & \text{ }& H & \text{ } & 2 & & 2 \\ \text{ } & \text{ }& T & \text{ } & 1 & & 3 \\ \text{ } & \text{ }& T & \text{ } & 0 & & 4 \\ \end{array}$

Now player A loses both of these games. For good measure, we show one more simulation.

$\begin{array}{ccccccc} \text{Game} & \text{ } & \text{Coin Tosses} & \text{ } & \text{Coins of Player A} & \text{ } & \text{Coins of Player B} \\ \text{ } & \text{ } & \text{ } & \text{ } & \text{ } & \\ \text{ } & \text{ }& \text{ } & \text{ } & 1 & & 3 \\ 5 & \text{ }& H & \text{ } & 2 & & 2 \\ \text{ } & \text{ }& H & \text{ } & 3 & & 1 \\ \text{ } & \text{ }& T & \text{ } & 2 & & 2 \\ \text{ } & \text{ }& H & \text{ } & 3 & & 1 \\ \text{ } & \text{ }& T & \text{ } & 2 & & 2 \\ \text{ } & \text{ }& H & \text{ } & 3 & & 1 \\ \text{ } & \text{ }& T & \text{ } & 2 & & 2 \\ \text{ } & \text{ }& T & \text{ } & 1 & & 3 \\ \text{ } & \text{ }& T & \text{ } & 0 & & 4 \\ \end{array}$

This one is a little more drawn out. Several tosses of tail in a row spells bad news for player A. When a coin is tossed long enough, there bounds to be some runs of tails. Since it is a fair coin, there bounds to be runs of head too, which benefit player A. Wouldn’t the runs of H cancel out the runs of T so that each player wins about half the time? To get an idea, we continue with 95 more simulations (to get a total of 100). Player A wins 23 of the simulated games and player B wins 77 of the games. So player A wins about 25% of the times. Note that A owns about 25% of the coins at the start of the game.

The 23 versus 77 in the 100 simulated games may be just due to luck for player B. We simulate 9 more runs of 100 games each (for a total of 10 runs with 100 games each). The following shows the results.

Ten Simulated Runs of 100 Games Each
$\begin{array}{ccccccc} \text{Simulated} & \text{ } & \text{Player A} & \text{ } & \text{Player B} & \text{ } & \text{Total} \\ \text{Runs} & \text{ } & \text{Winning} & \text{ } & \text{Winning} & \text{ } & \text{ } \\ \text{ } & \text{ } & \text{Frequency} & \text{ } & \text{Frequency} & \text{ } & \text{ } \\ \text{ } & \text{ } & \text{ } & \text{ } & \text{ } & \\ 1 & \text{ }& 23 & \text{ } & 77 & & 100 \\ 2 & \text{ }&34 & \text{ } & 66 & & 100 \\ 3 & \text{ }& 19 & \text{ } & 81 & & 100 \\ 4 & \text{ }& 24 & \text{ } & 76 & & 100 \\ 5 & \text{ }& 27 & \text{ } & 73 & & 100 \\ 6 & \text{ }& 22 & \text{ } & 78 & & 100 \\ 7 & \text{ }& 21 & \text{ } & 79 & & 100 \\ 8 & \text{ }& 24 & \text{ } & 76 & & 100 \\ 9 & \text{ }& 28 & \text{ } & 72 & & 100 \\ 10 & \text{ }& 24 & \text{ } & 76 & & 100 \\ \text{ } & \text{ } & \text{ } & \text{ } & \text{ } & \\ \text{Total} & \text{ }& 246 & \text{ } & 754 & & 1000 \\ \end{array}$

The simulated runs fluctuate quite a bit. Player A wins any where from 19% to 34% of the times. The results are no where near even odds of winning for player A. In the 1,000 simulated games, player A wins 24.6% of the times, roughly identical to the player A’s share of the coins at the beginning. If the simulation is carried many more times (say 10,000 times or 100,000 times), the overall winning probability for player A would be very close to 25%.

___________________________________________________________________________

Gambler’s Ruin Problem

Here’s a slightly more general description of the problem of gambler’s ruin.

Gambler’s Ruin Problem

Two gamblers, A and B, are betting on the tosses of a fair coin. At the beginning of the game, player A has $n_1$ coins and player B has $n_2$ coins. So there are $n_1+n_2$ coins between them. In each play of the game, a fair coin is tossed. If the result of the coin toss is head, player A collects 1 coin from B. If the result of the coin toss is tail, player A pays B 1 coin. The game continues until one of the players has all the coins. What is the probability that player A ends up with all the coins? What is the probability that player B ends up with all the coins?

Solution: Gambler’s Ruin Problem

The long run probability of player A winning all the coins is $\displaystyle P_A=\frac{n_1}{n_1+n_2}$.
The long run probability of player B winning all the coins is $\displaystyle P_B=\frac{n_2}{n_1+n_2}$.

In other words, the probability of winning for a player is the ratio of the number of coins the player starts with to the total numbers of coins. Turning it around, the probability of a player losing all his/her coins is the ratio of the number of coins of the other player to the total number of coins. Thus the player with the fewer number of coins at the beginning has a greater chance of losing everything. Think a casino. Say, it has 10,000,000 coins. You, as a gambler, have 100 coins. Then you would have a 99.999% chance of losing all your coins.

The 99.999% chance of losing everything is based on the assumption that all bets are at even odds. This is certainly not the case in a casino. The casino enjoys a house edge. So the losing probabilities would be worse for a gambler playing in a casino.

___________________________________________________________________________

Deriving the Probabilities

We derive the winning probability for a more general case. The coin that is tossed does not have to be a fair coin. Let $p$ be the probability that the coin toss results in a head. Let $q=1-p$. Suppose that there are $n$ coins initially between player A and player B.

Let $A_i$ be the probability that player A will own all the $n$ coins when player A starts the game with $i$ coins and player B starts with $n-i$ coins. On the other hand, let $B_i$ be the probability that player B will own all the $n$ coins when player A starts the game with $i$ coins and player B starts with $n-i$ coins.

The goal here is to derive expressions for both $A_i$ and $B_i$ for $i=1,2,\cdots,n-1$ and to show that $A_i+B_i=1$. The last point, though seems like common sense, is not entirely trivial. It basically says that the game will end in finite number of moves (it cannot go on indefinitely).

Another point to keep in mind is that we can assume $A_0=0$ and $A_n=1$ as well as $B_0=0$ and $B_n=1$. In the following derivation, $H$ is the event that the first toss is a head and $T$ is the event that the first toss is a tail.

Let $E$ be the event that player A owning all the coins when player A starts the game with $i$ coins and player B starts with $n-i$ coins, i.e. $A_i=P(E)$. First condition on the outcome of the first toss of the coin.

\displaystyle \begin{aligned} A_i&=P(E | H) \ P(H)+P(E | T) \ P(T) \\&=P(E | H) \ p+P(E | T) \ q \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (1) \end{aligned}

Consider the conditional probabilities $P(E | H)$ and $P(E | T)$. Note that $P(E | H)=A_{i+1}$. If the first toss is a head, then player A has $i+1$ coins and player B would have $n-(i+1)$ coins. At that point, the probability of player A owning all the coins would be the same as the probability of winning as if the game begins with player A having $i+1$ coins. Similarly, $P(E | T)=A_{i-1}$. Plug these into (1), we have:

$A_i=p \ A_{i+1}+q \ A_{i-1} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (2)$

Further derivation can be made on equation (2).

$A_i=p \ A_i+ q \ A_i=p \ A_{i+1}+q \ A_{i-1}$

$p \ A_{i+1}-p \ A_i=q \ A_i - q \ A_{i-1}$

$\displaystyle A_{i+1}-A_{i}=\frac{q}{p} \ (A_i-A_{i-1}),\ \ \ \ i=1,2,3,\cdots,n-1$

Plugging in the values $1,2,3,\cdots,n-1$ for $i$ produces the following $n-1$ equations.

\displaystyle \begin{aligned} &A_{2}-A_{1}=\frac{q}{p} \ (A_1-A_{0})=\frac{q}{p} \ A_1 \\&A_{3}-A_{2}=\frac{q}{p} \ (A_2-A_{1})=\bigg[ \frac{q}{p} \biggr]^2 \ A_1 \\&\ \ \ \cdots \\&A_{i}-A_{i-1}=\frac{q}{p} \ (A_{i-1}-A_{i-2})=\bigg[ \frac{q}{p} \biggr]^{i-1} \ A_1 \\&\ \ \ \cdots \\&A_{n}-A_{n-1}=\frac{q}{p} \ (A_{n-1}-A_{n-2})=\bigg[ \frac{q}{p} \biggr]^{n-1} \ A_1 \end{aligned}

Adding the first $i-1$ equations produces the following equations.

$\displaystyle A_i-A_1=A_1 \ \biggl[\frac{q}{p}+\bigg( \frac{q}{p} \biggr)^{2}+\cdots+\bigg( \frac{q}{p} \biggr)^{i-1} \biggr]$

$\displaystyle A_i=A_1 \ \biggl[1+\frac{q}{p}+\bigg( \frac{q}{p} \biggr)^{2}+\cdots+\bigg( \frac{q}{p} \biggr)^{i-1} \biggr] \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (3)$

There are two cases to consider. Either $\frac{q}{p}=1$ or $\frac{q}{p} \ne 1$. The first case means $p=\frac{1}{2}$ and the second case means $p \ne \frac{1}{2}$. The following is an expression for $A_i$ for the two cases.

$\displaystyle A_i = \left\{ \begin{array}{ll} \displaystyle i \ A_1 &\ \ \ \ \ \ \displaystyle \frac{q}{p}=1 \\ \text{ } & \text{ } \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (4) \\ \displaystyle \frac{ \displaystyle 1- \biggl(\frac{q}{p} \biggr)^i}{\displaystyle 1-\frac{q}{p}} A_1 &\ \ \ \ \ \ \displaystyle \frac{q}{p} \ne 1 \end{array} \right.$

The above two-case expression for $A_i$ is applicable for $i=2,3,\cdots,n$. Plugging $n$ into $i$ with $A_n=1$ gives the following expression for $A_1$:

$\displaystyle A_1 = \left\{ \begin{array}{ll} \displaystyle \frac{1}{n} &\ \ \ \ \ \ p=\frac{1}{2} \\ \text{ } & \text{ } \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (5) \\ \displaystyle \frac{\displaystyle 1-\frac{q}{p}}{1-\biggl( \displaystyle\frac{q}{p} \biggr)^n} &\ \ \ \ \ \ p \ne \frac{1}{2} \end{array} \right.$

Plugging $A_1$ from (5) into (4) gives the following:

$\displaystyle A_i = \left\{ \begin{array}{ll} \displaystyle \frac{i}{n} &\ \ \ \ \ \ p=\frac{1}{2} \\ \text{ } & \text{ } \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (6) \\ \displaystyle \frac{1-\biggl( \displaystyle \frac{q}{p} \biggr)^i}{1-\biggl( \displaystyle \frac{q}{p} \biggr)^n} &\ \ \ \ \ \ p \ne \frac{1}{2} \end{array} \right.$

The expression for $A_i$ in (6) is applicable for $i=1,2,\cdots,n$. For the case of $p=\frac{1}{2}$, the probability of player A owning all the coin is the ratio of the initial amount of coins of player A to the total number of coins, identical to what is stated in the previous section. Recall that $B_i$ is the probability that player B will end up owning all the coins when initially player A has $i$ coins and player B has $n-i$ coins. By symmetry, the following gives the expression for $B_i$.

$\displaystyle B_i = \left\{ \begin{array}{ll} \displaystyle \frac{n-i}{n} &\ \ \ \ \ \ q=\frac{1}{2} \\ \text{ } & \text{ } \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (7) \\ \displaystyle \frac{1- \biggl(\displaystyle \frac{p}{q} \biggr)^{n-i}}{\displaystyle 1- \biggl(\frac{p}{q} \biggr)^n} &\ \ \ \ \ \ q \ne \frac{1}{2} \end{array} \right.$

For the case $p=\frac{1}{2}$, which is equivalent to $q=\frac{1}{2}$, it is clear that $A_i+B_i=1$. For the case $p \ne \frac{1}{2}$, the following shows that $A_i+B_i=1$.

\displaystyle \begin{aligned} A_i+B_i&=\frac{1-\biggl( \displaystyle \frac{q}{p} \biggr)^i}{1-\biggl( \displaystyle \frac{q}{p} \biggr)^n}+\frac{1- \biggl(\displaystyle \frac{p}{q} \biggr)^{n-i}}{\displaystyle 1- \biggl(\frac{p}{q} \biggr)^n} \\&\text{ } \\&=\frac{p^n-p^n\biggl( \displaystyle \frac{q}{p} \biggr)^i}{p^n-q^n}+\frac{q^n- q^n \biggl(\displaystyle \frac{p}{q} \biggr)^{n-i}}{\displaystyle q^n- p^n}\\&\text{ } \\&=\frac{p^n-p^{n-i} \ q^i}{p^n-q^n}-\frac{q^n- q^i \ p^{n-i}}{\displaystyle p^n- q^n} \\&\text{ } \\&=\frac{p^n-q^n}{p^n-q^n}=1 \end{aligned}

The fact that $A_i+B_i=1$ shows that the gambling game discussed here has to end after certain number of plays and that it will not continue indefinitely.

___________________________________________________________________________

Further Discussion

The formulas derived here are quite profound, not to mention impactful and informative for anyone who gambles. More calculations and discussion can be found here in a companion blog on statistics.

___________________________________________________________________________
$\copyright$ 2017 – Dan Ma

# The problem of points

There are two celebrated problems in probability that originated from the French professional gambler Chevalier de MÃ©rÃ© (1607-1684). The problems were solved jointly by Blaise Pascal (1623-1662) and Pierre de Fermat (1601-1665) in a series of letters. The ideas discussed in these letters were often credited with having started probability theory. In a previous post, we discuss one of the problems posed by Chevalier de MÃ©rÃ© to Pascal (the dice problem). In this post, we discuss the second problem – the problem of points.

___________________________________________________________________________

Describing the Problem

Here’s a description of the famous problem of points. Two players play a game of chance with the agreement that each player puts up equal stakes and that the first player who wins a certain number of rounds (or points) will collect the entire stakes. Suppose that the game is interrupted before either player has won. How do the players divide the stakes fairly?

It is clear that the player who is closer to winning should get a larger share of the stakes. Since the player who had won more points is closer to winning, the player with more points should receive a larger share of the stakes. How do we quantify the differential?

To describe the problem in a little more details, suppose that two players, A and B, play a series of points in a game such that player A wins each point with probability $p$ and that player B wins each point with probability $1-p$. The first player to win $T$ points wins the game. Suppose that the game is stopped for some reason. At the time of stopping, player A has won $a$ points and player B has won $b$ points with $a and $b. How do they divide the stakes? Note that the pot is contributed equally by the two players.

In attacking the problem, Pascal’s idea is that the share of the stakes that is received by a player should be proportional to his/her probability of winning if the game were to continue at the point of stopping. Let’s explore this idea by looking at examples.

___________________________________________________________________________

Looking at the Problem thru Examples

The following examples are based on the following rule. Let’s say two players (A and B) play a series of points with equal probability of winning a point at each round. Each player puts up a stake of 32. The first player who wins four points take the entire stakes.

Example 1 (Fermat’s Approach)
Suppose that player A has won 2 points and player B has won one point right before the termination of the game. How can the stakes be divided fairly?

In the analysis, we assume that the game continues. Then player A needs 2 more points to win while player B needs 3 more points to win. We would like to calculate the probability that player A wins 2 points before player B winning 3 points. Consider the next 2 + 3 – 1 = 4 rounds (assuming one point per round). If player A wins at least 2 points in the next 4 rounds, player A win the game. The complement of this probability would be the probability that player B wins the game.

Let S (success) be the event that player A wins a point and let F (failure) be the event that player A loses a point (i.e. player B winning the point). Let’s write out all the outcomes of playing 4 points (this was the approach of Fermat). There are 16 such outcomes.

$\begin{array}{rrrrrr} 1 & SSSS & * & & \text{ } & \\ 2 & SSSF & * & & \text{ } & \\ 3 & SSFS & * & & \text{ } & \\ 4 & SSFF & * & & \text{ } & \\ 5 & SFSS & * & & \text{ } & \\ 6 & SFSF & * & & \text{ } & \\ 7 & SFFS & * & & \text{ } & \\ 8 & SFFF & \text{ } & & \text{ } & \\ 9 & FSSS & * & & \text{ } & \\ 10 & FSSF & * & & \text{ } & \\ 11 & FSFS & * & & \text{ } & \\ 12 & FSFF & \text{ } & & \text{ } & \\ 13 & FFSS & * & & \text{ } & \\ 14 & FFSF & \text{ } & & \text{ } & \\ 15 & FFFS & \text{ } & & \text{ } & \\ 16 & FFFF & \text{ } & & \text{ } & \\ \end{array}$

Player A wins In eleven of the outcomes (the ones with asterisk). Note that there are at least 2 S’s in the outcomes with asterisk. Thus the probability of player A winning is 11/16 = 0.6875. At the time of stopping the game, player A has a 68.75% chance of winning (if the game were to continue). The share for player A is 0.6875 x 64 = 44.

The example demonstrates the approach taken by Fermat. He essentially converted the original problem of points into an equivalent problem, i.e. finding the probability of player A winning the game if the game were to continue. Then he used combinatorial methods to count the number of cases that result in player A winning. In this example, the additional four points that are to be played are fictitious moves (the moves don’t have to be made) but are useful for finding the solution. The only draw back in Fermat’s approach is that he used counting. What if the number of points involved is large?

Example 2 (Pascal’s Approach)
The specifics of the example are the same as in Example 1. The listing out all possible cases in Example 1 makes the solution easy to see. But if the number of points is large, then the counting could become difficult to manage. What we need is an algorithm that is easy to use and is easy to implement on a computer.

Pascal essentially had the same thinking as Fermat, i.e. to base the solution on the probability of winning if the game were to continue. Pascal also understood that the original problem of points is equivalent to the problem of playing an additional series of points. In this example, playing additional 2 + 3 – 1 = 4 points. As in Example 1, we find the probability that player A wins 2 or more points in this series of 4 points. Pascal’s way to find this probability was based on what are now known as the Pascal’s triangle and the binomial distribution. We would use the following modern day notation:

$\displaystyle \sum \limits_{j=2}^4 \ \binom{4}{j} \ \frac{1}{2^4}=6 \times \frac{1}{2^4}+4 \times \frac{1}{2^4}+\frac{1}{2^4}=\frac{11}{16}=0.6875$

Note that the above probability of 0.6875 is the probability of having at least 2 successes in 4 trials (with 0.5 probability of success in each trial). Anyone with a good understanding of the binomial distribution can carry out the calculation (or use software). Of course, this mathematical construct came from Pascal! To the contemporaries of Pascal and Fermat, this concept was definitely not commonplace.

Example 3
Suppose that player A has won 1 point and player B has won no point at the time of termination of the game. How can the prize money be divided fairly?

Based on the discussion of Example 1 and Example 2, player A needs to win at least 3 points to win the game and player B needs to win 4 or more points to win the game. The extended series of points would have 3 + 4 – 1 = 6 points. Player A then needs to win at least 3 points out of 6 points (at least 3 successes out of 6 trials). The following gives the probability of player A winning the extended series of plays.

$\displaystyle \sum \limits_{j=3}^6 \ \binom{6}{j} \ \frac{1}{2^6}=\frac{42}{64}=0.65625$

With the total stakes being 64, the share for player A would be 64 x 42/64 = 42. The share for player B would be 22.

___________________________________________________________________________

General Discussion

We now discuss the ideas that are brought up in the examples. As indicated above, two players, A and B, contribute equally to the stakes and then play a series of points until one of them wins $T$ points. The probability that player A wins a round (one point in each round) is $p$ and the probability that player B wins a point is $1-p$. Suppose that the game is stopped for some reason before either player has won. At the time of stopping, player A has won $a$ points and player B has won $b$ points with $a and $b. Let $n=T-a$ and $m=T-b$. The key to solving the problem of points is to look at an extended play of $n+m-1$ points.

Here’s the great insight that came from Pascal and Fermat. They looked forward and not backward. They did not base the solution on the number of points that are already won. Instead, they focused on an extended series of points to determine the share of the winning. This additional play of points is “fictitious” but it helps clarify the process. In essence, they turned the original problem of points into a problem about this additional play of $n+m-1$ points.

The original problem is: what is the fair share for player A when the game is stopped prematurely with player A having won $a$ points and player B having won $b$ points? The equivalent problem is: what is the probability of player A winning at least $n$ points of the next $n+m-1$ points where $n=T-a$ and $m=T-b$ (assuming the game has not stopped). Let’s call this probability $P(n,m)$. Let’s examine the setting of this probability. Each point is like a Bernoulli trial – either a success (player A winning it) or a failure (player B winning it). There are $n+m-1$ trials. The probability of success is $p$ in each trial. We wish to find the probability that are at least $n$ successes. What is being described is a binomial distribution. The probability being sought is:

$\displaystyle P(n,m)=\sum \limits_{j=n}^{n+m-1} \ \binom{n+m-1}{j} \ p^j \ (1-p)^{n+m-1-j} \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (1)$

where $n=T-a$, $m=T-b$ and that $a$ is the number of points won by player A and $b$ is the number of points won by player B at the time the game is terminated.

The probability $P(n,m)$ is the probability of player A winning the game if the game were to continue at the point of termination. This probability $P(n,m)$ is the proportion of the stakes that would be awarded to player A. Of course, the proportion that should be awarded to player B would be $1-P(n,m)$. The quantity $P(n,m)$ can be obtained from the given parameters and by using any software that has a function for the binomial distribution.

The problem of points seems to have an easy solution since the answer $P(n,m)$ is so accessible. Any one who understands the binomial distribution can comprehend. It is also easy to compute probabilities for a binomial distribution using calculator or software. One thing to keep in mind is that the solution looks accessible now because of the tools and concepts that came from trails blazed by Pascal and Fermat (and because of the computing tools that we have). Tools and concepts such as Pascal’s triangle and binomial distribution were unknown to people at the time of Pascal and Fermat.

___________________________________________________________________________

Working Backward

For us, the calculation in $(1)$ is easily done using calculator or software. Pascal did not calculate $P(n,m)$ directly and instead perform the calculation backward by using the following formula.

$P(n,m)=p \times P(n-1,m)+(1-p) \times P(n,m-1) \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (2)$

The formula can be derived mathematically. But doing that is not necessary. The quantity $P(n,m)$ is the probability that player A will win $n$ points before player B winning $m$ points. We can derive the above formula by conditioning on the outcome of the first point. The quantity $P(2,3)$ is calculated in Example 1 and Example 2. It is the average of two similar probabilities with smaller parameters.

$P(2,3)=\frac{1}{2} \times P(1,3)+\frac{1}{2} \times P(2,2)$

Based on the recursive formula in $(1)$, Pascal built up the answer backward, similar to the way a computer program is written. In fact, this recursive approach allows us to solve not just for one scenario, but for all the scenarios in a game of $T$ points.

Example 4
We now revisit the problem in Examples 1 and 2. Recall that the game is to play for 4 points, i.e. the first player winning 4 points collects the entire stakes of 64 (32 is contributed by each player). Each player earns a point with probability 0.5. We now show how to divide the stakes when the game is stopped at every possible stopping point.

The following diagram (Figure 1) shows the table for the share awarded to player A. The table is empty except for the top row and rightmost column (the numbers in red). The number 64 shown in the last column would be the amount awarded to player A because player A has won 4 points. The number 0 in the top means that player B has won 4 games. So player A gets nothing. Note that the bottom row highlighted in orange shows the numbers of points that have been won player A. The bottom row highlighted in blue shows the remaining points that player A needs to win in order to win the entire stakes (these are the fictitious points). Similarly, the columns highlighted in orange and blue on the left show the same information for player B.

Figure 1 – The share of the stakes awarded to player A

Now, we can use the recursive formula in $(1)$ to fill the table. Basically each cell is the average of the number above it and the number to the right. The parameter $n$ in $P(n,m)$ is a number in the blue row. The parameter $m$ in $P(n,m)$ is a number in the blue column. The following shows the results.

Figure 2 – The share of the stakes awarded to player A

For example, when player A has won 2 points and player B has won 1 point, the share for player A is 44 (the average of 32 and 56), the same answer as in Example 1 and Example 2. When player A has won 2 points and player B as won 2 points, both players are in equally competitive positions. Then each player gets 32. When player A has won 2 points and player B as won 3 points, the share for player A is 16 (the average of 0 and 32).

Essentially the formula in $(2)$ is the idea of using smaller steps rather than the entire extended play of $n+m-1$ points. This idea of smaller steps was preferred by Pascal. At the point where player A needs $n$ more points to win and player B needs $m$ more points to win, the idea is to play one more point. Suppose that the players know the awards to the two players after one more round. Then they should split the difference between the future awards. The calculation should begin at the point where each player only needs one more point to win (the cell with 32 in Figure 2). In that cell, we know the awards after one additional round. Taking the average of 0 and 64 gives 32. From that cell, we move down and move left on the table. Keep repeating the process until the entire table is filled in.

There is a way to tweak the table approach to work for unequal winning probability of a point. Let’s say the probability of player A winning a point is 0.6. Then the probability of player B winning a point is 0.4. The value of a given cell in the table would be the weighted average of the cell on the right (0.6 weight) with the cell above it (0.4 weight). When we know the results from playing one more round, we assign 0.6 to the result of player A winning and 0.4 to the result of player B winning. The following table shows the results.

Figure 3 – The share of the stakes awarded to player A (with 0.6 weight)

The direct formula $(1)$ or the table approach using the recursive formula $(2)$ can be easily programmed in a computer. For Pascal, the table approach is a very attractive option since the calculation can be built up from lower parameter values. In the above configuration, simply fill in the right column (the entire stakes going to player A) and the top row (player A getting nothing). Then the remaining cells are obtained by weighted average as described in formula $(2)$.

We present one more example.

Example 5
Suppose that player B is a casino and player A is a visitor at the casino playing for 12 points. The house edge is 2% so that the probability of player A winning a round is 0.48. If player A desires to leave after player A has won 9 points and the house has won 6 points, what is the proportion of the stakes that should be awarded to player A?

Playing for 12 points, player A needs 3 more points to win and the house needs 6 more points to win. So we need to analyze an extended play of 3 + 6 – 1 = 8 points. For player A to win the extended play, he needs to win at least 3 points.

$\displaystyle P(3,6)=\sum \limits_{j=3}^8 \ \binom{8}{j} \ 0.48^j \ 0.52^{8-j}=0.827631917$

The answer can be obtained by computing each term in the sum (from $j=3$ to $j=8$). Another way is to use the BINOMDIST function in Excel as follows:

= 1-BINOMDIST(2, 8, 0.48, TRUE) = 1-0.172368083 = 0.827631917

Based on the fair division method discussed in this blog post, player A deserves 82.76% of the stakes.

___________________________________________________________________________

Remarks

In their correspondence, Pascal and Fermat came up with convincing and consistent solution to the problem of points. The earlier solutions to the problem of points were not satisfactory (to all concerned) and are sometimes inconsistent. Division of stakes only basing on the numbers points that have been won may produce extreme results. For example, if player A has won 1 point and player B has won no points, then player A would get the entire stakes. For the game described in Figure 2, for the same scenario, player A gets 42 out of 64 (42 / 64 = 0.65625), which is far from 100%.

For more detailed information on the history of the problem of points, see “A History of Mathematics” by Victor J. Katz.

___________________________________________________________________________
$\copyright \ 2016 \text{ by Dan Ma}$

# When a gambler asked a mathematician for help

When a gambler consistently loses large sum of money, what can he or she do? When one particular gambler, Chevalier de MÃ©rÃ© (1607-1684), was losing a big fortune, he called a “mathematical help line”. In fact, his correspondence with Blaise Pascal (1623-1662) earned him a place in the history book. The problems that were presented by de MÃ©rÃ©, jointly worked on by Pascal and Pierre de Fermat (1601-1665), are regarded as the beginning of the emerging academic field of probability. Chevalier de MÃ©rÃ© was in need of help for two problems – the problem of points and on the dice problem that now bears his name. In this post we discuss the dice problem. The problem of points is discussed in the next post.

___________________________________________________________________________

The Dice Problem

There were two dice problems from Chevalier de MÃ©rÃ©. The first game involves four rolls of a fair die. In this game, de MÃ©rÃ© made bet with even odds on rolling at least one six when a fair die is rolled four times. His reasoning was that since getting a six in one roll of a die is $\frac{1}{6}$ (correct), the chance of getting a six in four rolls of a die would be $4 \times \frac{1}{6}=\frac{2}{3}$ (incorrect). With the favorable odds of 67% of winning, he reasoned that betting with even odds would be a profitable proposition. Though his calculation was incorrect, he made considerable amount of money over many years playing this game.

The second game involves twenty four rolls of a pair of fair dice. The success in the first game emboldened de MÃ©rÃ© to make even bet on rolling one or more double sixes in twenty four rolls of a pair of dice. His reasoning was that the chance for getting a double six in one roll of a pair of dice is $\frac{1}{36}$ (correct). Then the chance of getting a double six in twenty four rolls of a pair of dice would be $24 \times \frac{1}{36}=\frac{2}{3}$ (incorrect). He again reasoned that betting with even odds would be profitable too.

But experience showed otherwise. As he lost a lot of money, he realized something was not quite right with the second game. In 1654, he challenged his renowned friend Blaise Pascal to find an explanation. The solution emerged in a series of letters between Pascal and Fermat. Out of this joint effort, a foundation was laid for the idea of probability as an academic subject. One particular idea that emerged was the Pascal triangle. Another one was the binomial distribution. In fact, anyone who understand the binomial distribution can very quickly see the faulty reasoning of de MÃ©rÃ©.

___________________________________________________________________________

The Simulation

Before we get to the calculation, let’s simulate the games played by de MÃ©rÃ©. Using random numbers generated from using the Rand() function in Excel, we simulated 100,000 iterations of each of the games. In our 100,000 simulations of the first game – rolling a die four times, there are 51,380 iterations with at least one six. This suggests that de MÃ©rÃ©’s position would win more than half of the time, though not the $\frac{2}{3}$ odds that he believed. But it was profitable for him nonetheless.

In our 100,000 simulations of the second game – rolling a pair of dice 24 times, there are only 49,211 iterations with at least one double six. This seems to support that de MÃ©rÃ©’s position is a losing proposition, that he would be losing his bets more than half the time.

Of course, de MÃ©rÃ© could have done similar simulation, though in a much smaller scale, by rolling the dice himself (say, 100 times). He could have seen the light much sooner.

___________________________________________________________________________

The Calculation

Letâ€™s see why the first game was profitable for de MÃ©rÃ© and why the second game was not.

The First Game
In a roll of a die, there are six possible outcomes: 1, 2, 3, 4, 5, 6. If the die is fair, the probability of getting a six is $\frac{1}{6}$. Likewise, the probability of getting no six in one roll of a fair die is $\frac{5}{6}$.

The probability of getting no six in four rolls is:

$\displaystyle P(\text{no six in four rolls})=\frac{5}{6} \times \frac{5}{6} \times \frac{5}{6} \times \frac{5}{6}=\biggl(\frac{5}{6}\biggr)^4=0.482253$.

Thus in four rolls of a fair die, the probability of getting at least one six is:

\displaystyle \begin{aligned}P(\text{at least one six in four rolls})&=\displaystyle 1 - P(\text{no six in four rolls})\\&=1 - 0.482253\\&=0.517747\end{aligned}

Thus the probability of getting at least one six in four rolls of a fair die is 0.517747. Out of 100 games, de MÃ©rÃ© would on average win 52 games. Out of 1000 games, he would on average win 518 games. Suppose each bet is one French franc. Then de MÃ©rÃ© would gain 36 francs for each 1000 francs in wagered. Thus he had the house’s edge of about 3.6%.

The Second Game
In a roll of a pair of dice, there are a total of 36 possible outcomes (i.e. the six outcomes of the first die combined with the six outcomes of the second die). Out of these 36 outcomes, only one of them is a double six. So, the probability of getting a double six is $\frac{1}{36}$ in rolling a pair of dice. Likewise, the probability of not getting a double six is $\frac{35}{36}$.

The probability of getting no double six in 24 rolls of a pair of dice is:

\displaystyle \begin{aligned}P(\text{no double six in 24 rolls})= \biggl(\frac{35}{36}\biggr)^{24}=0.5086\end{aligned}

Thus the probability of getting at least one double six in 24 rolls is:

\displaystyle \begin{aligned}P(\text{at least one double six in 24 rolls})&=\displaystyle 1 - P(\text{no double six in 24 rolls})\\&=1 - 0.5086\\&=0.4914\end{aligned}

Thus the probability of getting at least one double six in 24 rolls of a pair of fair dice is 0.4914. On average, de MÃ©rÃ© would only win about 49 games out of 100 and his opposing side would win about 51 games out of 100 games. Out of 1000 games, he would on average win 491 games (the opposing side would win on average 509 games). With each bet as one franc, the opposing side of de MÃ©rÃ© would win 18 francs for each 1000 francs wagered (thus the opposing side having the house’s edge of about 1.8%).

The odds indicated by the simulations discussed above are in line with the calculated results. It would be interesting to known what action did de MÃ©rÃ© take after learning the answers. Maybe he stopped playing the second game and only played the first game. Maybe he modified the second game so that the odds of winning for him was at least even (or better).

___________________________________________________________________________
$\copyright \ 2016 \text{ by Dan Ma}$

# The game of poker dice and the multinomial theorem

This post presents an application of the multinomial theorem and the multinomial coefficients to the game of poker dice. See the previous post The multinomial theorem for a discussion of the multinomial theorem and multinomial coefficients.

The game of poker dice is different from the standard poker game. Instead of drawing five cards from a deck of $52$ cards, five fair dice are rolled. The resulting five scores from the dice form a poker dice hand. The possible hands are ranked as follows:

• Five of a kind: one score occurs five times (e.g. $2,2,2,2,2$).
• Four of a kind: two distinct scores appear, one score occursÂ four times and the other score occurs one time (e.g. $2,2,2,2,5$).
• Full house: two distinct scores appear, one score occurs three times and the other score occurs two times (e.g. $3,3,3,1,1$).
• Three of a kind: three distinct scores appear, one score occurs three times, the other two scores occur one time each (e.g. $2,2,2,3,6$).
• Two pair: three distinct scores appear, two of the scores occur two times each and the other score occurs once (e.g. $4,4,1,1,5$).
• One pair: four distinct scores appear, one score occurs two times and the other three scores occur one time each (e.g. $5,5,1,2,4$).
• High card: five distinct scores occur (e.g. $2,3,5,4,1$).

Â
In rolling $5$ dice, there are $6^5=7776$ ordered outcomes. For example, assuming that the five dice are rolled one at a time, $2,3,2,6,2$ indicates outcome that the first die results in a two and the second die results in a three and so on (this is a three of a kind). To find the probability of a three of a kind, we simply divide the number of ways such hands can occur by $7776$. We use the multinomial coefficients to obtain the number of outcomes for each type of poker dice hands.

Rolling $k$ dice (or rolling a die $k$ times) can also be regarded as the occupancy problem of assigning $k$ balls into $6$ cells. As will be shown below, the problem of computing the probabilities of poker dice hands is seen through the lens of the occupancy problem of randonly placing $5$ balls into $6$ cells. For example, five of a kind is equivalent to all five balls being placed in different cells. Three of a kind is equivalent to three of the balls being in one cell, and the other two balls in two other different cells. For discussion on the occupancy problems in this blog, see the following posts:

In placing $5$ balls into $6$ cells, we use $6$-tuples to indicate how many balls are in each of the $6$ cells. For example, $(0,3,1,0,0,1)$ denotes a three of a kind hand of $2,2,2,3,6$ (the score of two appearing three times, the score of three appearing one time and the score of six appearing one time). Note that the $6$ coordinates represent the six scores of a die (six cells) and the sum of the coordinates is $5$. The $6$-tuple of $(3,1,1,0,0,0)$ is also a three of a kind hand, representing the outcome that the score of one appearing three times, the score of two appearing one time and the score of three appearing one time. We use the multinomial coefficients to determine how many of the $7776$ ordered outcomes correspond to a $6$-tuple such as $(3,1,1,0,0,0)$. With respect to the occupancy problem, such $6$-tuples are called occupancy number sets.

The Multinomial Theorem
For any positive integer $n$ and any positive integer $k$, we have the following polynomial expansion:

$\displaystyle \biggl(x_1+x_2+ \cdots +x_n\biggr)^k=\sum \limits_{a_1+ \cdots +a_n=k} \frac{k!}{a_1! \ a_2! \cdots \ a_n!} \ \ x_1^{a_1} x_2^{a_2} \cdots x_n^{a_n}$

Remark
In addition to being a formula for polynomial expansion, there are two important interpretations of the multinomial theorem and multinomial coefficients. One is that of determining the number of ordered strings that can be formed using a set of alphabets. For example, with one $m$, four $i's$, four $s's$ and two $p's$, there are $\displaystyle \frac{11!}{1! \ 4! \ 4! \ 2!}=\text{34,650}$ possible $11$-letter strings that can be formed, of which $mississippi$ is one specific example.

Another interpretation is that of partitioning a set of distinct objects into several groupings where objects in each grouping are indistinguishable. For example, in a group of $11$ candidates, how many ways can we form four committees such that the Committee 1 has only one member, Committee 2 has four members, Committee 3 has four members and Committee 4 has two members (assuming that each person can only serve in one committee)? The answer, as in above example, is $\text{35,650}$.

Example 1
In a random poker dice hand, what is the probability of obtaining a $4$ two times, a $3$ one time, a $5$ one time and a $6$ one time? Note that this is a specific example of the poker dice hand of one pair.

We consider the $6$-tuple of $(0,0,1,2,1,1)$. We are trying to partition $5$ scores into four subgroups, one group having two identical scores of $4$, one group with a score of $3$, one group with a score of $5$ and one group with a score of $6$. Thus consider the following multinomial coefficient:

$\displaystyle \frac{5!}{1! \ 2! \ 1! \ 1!}=60$

So out of $\text{7,776}$ possible hands, $60$ of them satisfiy the condition that a $4$ appearing two times, a $3$ appearing one time, a $5$ appearing one time and a $6$ appearing one time. The probability is:

$\displaystyle \frac{60}{7776}=0.0077160494$

Example 2
What is the probability that one score appears two times, three other scores appear one time each in a random poker dice hand?

Here, we need to count all the possible poker dice hands of one pair. Both $(0,0,1,2,1,1)$ and $(2,1,1,1,0,0)$ are examples of one pair. In essense, we need to count all the occupancy number sets such that among the $6$ coordinates (cells), one of the cells is a $2$ and three of the cells are $1$. To this end, we apply the multinomial theorem twice, one time on the five rolls of dice and one time one the $6$ cells.

Consider the occupancy number set $(2,1,1,1,0,0)$. Note that the multinomial coefficient is $60$ as in Example $1$ (the first application of the multinomial thoerem). Now look at the $6$ coordinates of the occupancy number set $(2,1,1,1,0,0)$. We wish to partition these $6$ coordinates into three groupings, one with one $2$, one with three $1's$ and one with two $0's$. The following is the multinomial coefficient (the second application of the multinomial theorem):

$\displaystyle \frac{6!}{1! \ 3! \ 2!}=60$

Thus the number of possible poker dice hands of one pair is: $60 \times 60=\text{3,600}$ and for a random poker dice hand, the probability that it is a one pair is:

$\displaystyle \frac{3600}{7776}=0.462962963$

Remark
Example $2$ provides the algorithm for computing the remaining poker dice hand probabilities. The key is to apply the multinomial coefficients twice, one time on a representative occupancy number set, the second time on the six cells (the six faces of a die in this case). Then the number of poker dice hands in question is the product of the two multinomial coefficients.

Example 3
What is the probability that a random poker dice hand is three of a kind?

Consider the occupancy number set of $(3,1,1,0,0,0)$. The associated multinomial coefficient for the five rolls of dice is:

$\displaystyle \frac{5!}{3! \ 1! \ 1!}=20$

Now partition the six cells into three groupings (one $3$, two $1's$, three $0's$):

$\displaystyle \frac{6!}{1! \ 2! \ 3!}=60$

Thus the probability that a random poker hand is three of a kind is:

$\displaystyle \frac{20 \times 60}{7776}=0.1543209877$

Summary
The following are the probabilities of poker dice hands.

$\displaystyle P(\text{five of a kind})=\frac{6}{7776}$

$\displaystyle P(\text{four of a kind})=\frac{150}{7776}$

$\displaystyle P(\text{full house})=\frac{300}{7776}$

$\displaystyle P(\text{three of a kind})=\frac{1200}{7776}$

$\displaystyle P(\text{two pair})=\frac{1800}{7776}$

$\displaystyle P(\text{one pair})=\frac{3600}{7776}$

$\displaystyle P(\text{high card})=\frac{720}{7776}$

________________________________________________________________________
$\copyright \ \text{2010 - 2015 by Dan Ma}$ (Revised March 28, 2015)