Markov Chains (prob140.MarkovChain
)¶
Construction¶
Using a Table¶
You can use a 3 column table (source state, target state, transition probability) to construct a Markov Chain. The functions Table.transition_probability() or Table.transition_function() are helpful for constructing such a Table. From there, call Markov_chain.from_table() to construct a Markov Chain.
In [1]: mc_table = Table().states(make_array("A", "B")).transition_probability(make_array(0.5, 0.5, 0.3, 0.7))
In [2]: mc_table
Out[2]:
Source | Target | Probability
A | A | 0.5
A | B | 0.5
B | A | 0.3
B | B | 0.7
In [3]: MarkovChain.from_table(mc_table)