convert Viterbi to logarithmic to avoid underflow