viterbi
viterbi copied to clipboard
Off-by-1-error in backtracking?
Looking at
https://github.com/daoliker/viterbi/blob/master/viterbi_decoder.cc#L35
shouldn't that be
hid_seq[t] = psi[t + 1][hid_seq[t + 1]];
it seems off-by-one for my glance; especially note that this way hid_seq[0]
will always be zero which I think is not intended.
Hi @Sciss, I have noticed the same thing. The Backtracking equation states that you should search in the psi array at position t+1 and not position t. I have written the Viterbi algorithm in JavaScript and was trying to make a litmus test by checking what other developers have written. A valid implementation in python is here: https://people.eng.unimelb.edu.au/tcohn/comp90042/HMM.py I was about to open an issue as well, but you beat me to it ;)