Hidden Markov Models: The Backwards Algorithm

Given an output sequence and a Hidden Markov Model, the backward algorithm determines the probability that the given model has emitted the sequence of observations by building a matrix of probabilities starting with the final observation and incrementally adding the previous observation at each step.

To implement this algorithm, I'll use the example of a dice roller who claims to have fair die. Given a sequence of observations we will consider a few HMMs to see the probability that the sequence we observe was generated by fair die vs loaded die.