The following working program uses
Graph and Markov Chain
P = {{1/2, 1/2, 0, 0}, {1/2, 1/2, 0, 0}, {1/4, 1/4, 1/4, 1/4}, {0, 0,
0, 1}}; proc = DiscreteMarkovProcess[3, P];
Graph[proc, GraphStyle -> "DiagramBlue",
EdgeLabels ->
With[{sm = MarkovProcessProperties[proc, "TransitionMatrix"]},
Flatten@Table[DirectedEdge[i, j] -> sm[[i, j]], {i, 2}, {j, 2}]]]
sm = MarkovProcessProperties[proc, "TransitionMatrix"]
sm == P
Since I couldn’t make it work for larger matrices, I clarified in the last two lines that sm is just P. But, if I try to replace sm by P in the first part, all hell breaks loose. So, I tried copy paste changing just P to a larger matrix, but this does not work. Why?
P = {{0, 1/4, 1/2, 1/4, 0, 0}, {0, 1, 0, 0, 0, 0}, {0, 0, 1/3, 0, 2/3,
0}, {0, 0, 0, 0, 0, 1},
{0, 0, 1/4, 0, 3/4, 0}, {1/4, 0, 0, 0, 3/4, 0}};
P // MatrixForm
proc = DiscreteMarkovProcess[1, P];
Graph[proc,
EdgeLabels ->
With[{sm = MarkovProcessProperties[proc, "TransitionMatrix"]},
Flatten@Table[DirectedEdge[i, j] -> sm[[i, j]], {i, 6}, {j, 6}]]]