Related, but it seems like the respondents there misunderstood the question.
The following errors as DiscreteMarkovProcess::invsm
:
p = DiscreteMarkovProcess[10, Graph[{10, 11}, {10 \[DirectedEdge] 11}]];
RandomFunction[p, {0, 5}]
If we simply change 10, 11 to 1, 2, it works without issue:
q = DiscreteMarkovProcess[1, Graph[{1, 2}, {1 \[DirectedEdge] 2}]];
RandomFunction[q, {0, 5}]
The problem appears to be that DiscreteMarkovProcess
has relabeled the vertices of the graph to 1 and 2, since:
p2 = DiscreteMarkovProcess[1, Graph[{10, 11}, {10 \[DirectedEdge] 11}]];
RandomFunction[p2, {0, 5}]
works as q
did (the only change from p
is the first argument to DiscreteMarkovProcess
). This should not happen in any reasonable interpretation that I can see.
Is there a way to make Mathematica work with the vertex names I have provided (without relabelling them 1, 2, …), or else of recovering the mapping 10 -> 1, 11 -> 2
which it turns out Mathematica has applied above?
MarkovProcessProperties[ ]
shows you how to manually cope with that. Many graph functions in Mma share this idiosyncrasy. (Not that I'm pleased with it) $\endgroup$VertexList
determines the Markov state with which it will be identified. $\endgroup$g
):MapIndexed[(state[#1] = #2[[1]]) &, VertexList[g]]
. This defines a functionstate
that turn a label into a state number. $\endgroup$