Last updated 4 years ago
def viterbi(n): S_(n-1),P_(n-1) = viterbi(n-1) max_p=0 for s_i,p_i->j in StatusMatrix[S_(n-1)]: p = p_i->j * P_(n-1) if p>max_p : max_p=p S_n=s_i return S_n,max_p