It is well known that the Viterbi algorithm can be used to estimate the optimal state sequence that generates the observed sequence. Detail is described in literature[2].