Implementation of a Hidden Markov Model