Markov chains in Python