SciPy

prob140.MarkovChain.prob_of_path

MarkovChain.prob_of_path(starting_condition, path)[source]

Finds the probability of a path given a starting condition

Parameters:

starting_condition : state or Distribution

If a state, finds the probability of the path starting at that state. If a Distribution, finds the probability of the path with the first element sampled from the Distribution

path : array

Array of states

Returns:

float

probability

Examples

>>> mc = Table().states(make_array("A", "B")).transition_probability(make_array(0.5, 0.5, 0.3, 0.7)).toMarkovChain()
>>> mc.prob_of_path('A', make_array('A', 'B','B'))
0.175
>>> start = Table().states(make_array("A", "B")).probability(make_array(.8, .2))
>>> mc.prob_of_path(start, make_array('A', 'A', 'B','B'))
0.14
>>> 0.175 * 0.8
0.14