Python Markov Chain utility functions