I have a Python dictionary with state transition probabilities of a Markov-chain model.
dict_m = {('E', 'F'): 0.29032258064516131, ('D', 'F'): 0.39726027397260272, ('D', 'D'): 0.30136986301369861, ('E', 'D'): 0.32258064516129031, ('E', 'E'): 0.38709677419354838, ('D', 'E'): 0.30136986301369861, ('F', 'F'): 0.68152866242038213, ('F', 'E'): 0.10191082802547771, ('F', 'D'): 0.19108280254777071, ('F', 'H'): 0.025477707006369428, ('H', 'F'): 1.0}
Suppose I have a data sequence like following. State transitions are from D to E, E to F, F to E..etc.
s = ['D','E','F','E','E','F','H','F']
Now I need to calculate the probability value by multiplying the probabilities in dict_m. In this case probability of all state transition is
probability = 0.301370*0.290323*0.101911*0.387097*0.290323*0.025478*1.000000
Can anybody help me to formulate this.
print zip(s,s[1:])
[('D', 'E'), ('E', 'F'), ('F', 'E'), ('E', 'E'), ('E', 'F'), ('F', 'H'), ('H', 'F')]