« View all new features in
Mathematica
9
◄
previous

next
►
New in
Mathematica
9
›
Markov Chains and Queues
Coin Flip Sequences
When flipping a fair coin until either HHT or HTT are first reached, on average it takes longer for HHT to occur than for HTT, even though the sequence probabilities are equal.
In[1]:=
X
proc = DiscreteMarkovProcess[ 1, {{1/2, 1/2, 0, 0, 0, 0}, {0, 0, 1/2, 1/2, 0, 0}, {0, 0, 1/2, 0, 1/2, 0}, {0, 1/2, 0, 0, 0, 1/2}, {0, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 0, 1}}];
In[2]:=
X
Graph[{"Start", "H", "HH", "HT", "HHT", "HTT"}, proc, ImageSize > Medium]
Out[2]=
Find the mean number of coin flips to reach HHT.
In[3]:=
X
Mean[FirstPassageTimeDistribution[proc, 5]] // N
Out[3]=
Find the mean number of coin flips to reach HTT.
In[4]:=
X
Mean[FirstPassageTimeDistribution[proc, 6]] // N
Out[4]=