Skip to content

Instantly share code, notes, and snippets.

@lettergram
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lettergram/a74ce8a156bd7b6ff774 to your computer and use it in GitHub Desktop.
Save lettergram/a74ce8a156bd7b6ff774 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
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 = 10
print(Markov(p, s, steps))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment