Forward-Backward and Viterbi Algorithm for HMM