Analyze a Tennis Game

 In[1]:= Xproc = With[{p = 3/5, q = 2/5}, DiscreteMarkovProcess[17, ({ {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, p, q, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {p, 0, q, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, q, p, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {p, 0, 0, q, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, q, 0, 0, p, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {p, 0, 0, 0, 0, q, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, q, 0, 0, p, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, p, 0, 0, 0, q, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, q, 0, 0, 0, 0, p, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, p, q, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, p, q, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, p, q, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, p, q, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, p, q, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, p, q, 0} })]];
 In[2]:= XGraph[proc, VertexSize -> {"Scaled", 0.07}, VertexLabels -> Thread[Range[17] -> Map[Placed[Style[#, {Bold}], Center] &, states = {"GameA", "GameB", "Deuce", "AdvA", "AdvB", "40-15", "15-40", "40-0", "30-15", "15-30", "0-40", "30-0", "15-15", "0-30", "15-0", "0-15", "0-0"}]], ImageSize -> Large, ImagePadding -> 25]

In a game of tennis between two players, suppose the probability of the server winning a point is . Visualize the random walk graph for , with 17 states.

 Out[2]=

Find the probability of the server's winning the game for .

 In[3]:= XPDF[proc[\[Infinity]], 1] // N
 Out[3]=

Find the mean time to absorption, that is, the number of points played.

 In[4]:= XN[Mean[FirstPassageTimeDistribution[proc, {1, 2}]]]
 Out[4]=

Find the mean number of states visited.

 In[5]:= XMarkovProcessProperties[proc, "TransientTotalVisitMean"] // N
 Out[5]=

Find the average number of times the score will be tied at deuce.

 In[6]:= XMarkovProcessProperties[proc, "TransientVisitMean"][[1]] // N
 Out[6]=