viterbi icon indicating copy to clipboard operation
viterbi copied to clipboard

Off-by-1-error in backtracking?

Open Sciss opened this issue 5 years ago • 1 comments

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.

Sciss avatar Aug 27 '18 15:08 Sciss

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 ;)

Mary62442 avatar Jan 03 '19 16:01 Mary62442