Waiting Time Markov Chain Python Code