This post presents an application of Markov chains and related ideas. This post models the Gambler’s Ruin Problem as a Markov chain, and presents its solution.

There are many variations of the problem with the same essence. Here is another.

Two players A and B play a game with the following rules:

- A fair coin is tossed. Player A wins on heads, and Player B wins on tails.
- The player that loses transfers one unit of money to the winner, and then the game is continued, and the coin is tossed again.
- The game terminates when one of the players is ruined, i.e., has zero money left to play with.

The money they start with is $R_A$ and $R_B$ respectively. We need to find the probability of winning of a player.

Let us simplify the problem by setting small, concrete values of $R_A$ and $R_B$ to 1 and 2 respectively. At each step of the game, $R_A$ can increment or decrement by one, with equal probabilities. Since the total money in game is 3, there are four possibilities for $R_A$ in the game: . The game ends when $R_A$ is either 0 (A loses all the money) or 3 (B loses all the money). The game continues for the other two states.

Let us denote this game as a state transition diagram. A state represents the current amount of money A has, and an edge represents a transition between states. Note that the state of player A alone is sufficient to capture the state of the game, as the total money in the game is constant, i.e, $R_A + R_B = 3$. The following figure shows the state transition diagram. A node denotes the money that player A has, i.e., $R_A$. When the game is in state 2, player A can lose to go to state 1 or she may win to go to state 3. The probability in states 1 and 2 for winning and losing the current step is determined by tossing a fair coin and is 0.5 each. The states 0 and 3 indicate termination of the game. Once these states are attained there is no way going to another state.

The game follows the Markov property. The conditional probability of the next move is independent of the previous states. Moreover, the Markov chain described by the transitions is an absorbing Markov chain. States 0 and 3 are absorbing states, and these absorbing states can be reached by all the other states in one or more steps. This implies that the game will reach a steady state.

The transition distribution for the game is the following:

Let $\nu$ denote the probability distribution of states, i.e., probability of the game being in any particular state. It is a 1x4 matrix, representing the probability of each state. If $\nu_t$ is the probability distribution of states at time $t$, then $\nu_{t+1}$ can be computed by the following equation:

We are given that the initial value of $P_A$ is 1, therefore, the initial probability distribution is

We can compute the probability distribution after one step, two steps, three steps, ten steps and hundred steps as follows:

$\nu_{100}$ denotes that after 100 steps the probability that the game is in losing state (state 0) is 2/3, and the game is in winning state (state 3) is 1/3. Moreover, the probability that game is still not terminated is almost zero, i.e., the probability being in states 1 and 2.

A game between A and B, with starting money 1 and 2 respectively, has 1/3 probability such that A wins. On the other hand, player B, who starts with more money, has 2/3 (higher) probability of winning. For a general case, we can prove that the probability that A wins is $R_A/(R_A+R_B)$. In other words, it is better to start with more money than the opponent. Note that the general can can be solved by a similar argument. It would require constructing a transition matrix of size $(R_A+R_B+1) X (R_A+R_B+1)$, and then computing the limiting distribution.

Markov chains can be used to solve the problems that obey the Markov property. One has to just model the problem as a Markov chain and the rest comes for free. One can then reason in terms the existing results on Markov chains.

© 2018-19 Manjeet Dahiya