viterbi inner loop written in clojure for comparing JS version