Simulating a discrete-time Markov chain