Changed to use itertools. Still have transition probability summation to implement.