Skip to content

Instantly share code, notes, and snippets.

@venuktan
Created April 22, 2014 22:38
Show Gist options
  • Save venuktan/11196779 to your computer and use it in GitHub Desktop.
Save venuktan/11196779 to your computer and use it in GitHub Desktop.
import numpy as np
def Markov(p, s, steps):
for i in range(steps):
s = s * p
print s
return s
p = np.matrix('.5, .5, 0, 0, 0, 0; .4, .1, .5, 0, 0, 0; 0, .3, .2, .5, 0, 0; 0, 0, .2, .3, .5, 0; 0, 0, 0, .1, .4, .5; 0, 0, 0, 0, 0, 1')
s = np.matrix('1, 0, 0, 0, 0, 0')
steps = 55
print(Markov(p, s, steps))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment