Example 4 for Markov Chain -《赌徒的下场-Gambler‘s Ruin》

Consider two gamblers, A and B, who have a combined fortune of  n dollars. They bet one dollar each on the toss of a coin.

  • If the coin turns up heads, A wins a dollar from B.
  • If the coin turns up tails, B wins a dollar from A.

Suppose the successive coin tosses are independent, and the coin turns up heads with probability p and tails with probability q=1-p.  The game ends when either A or B is broken (or ruined).  Let Xk denote the fortune of gambler A after the k-th toss. 

Plot the state transition diagram.

{Xk, k>=0} is a simple random walk on {0,1,2,…, n} with absorbing barriers at 0 and n.

Calculate the stationary distribution of Xk