viterbi_g function

Viterbi algorithm for state decoding in inhomogeneous HMMs