powered by
Viterbi algorithm for decoding states
viterbi(delta, Gamma, allprobs)
Vector of decoded states of length n
Initial or stationary distribution of length N
Transition probability matrix of dimension c(N,N)
Matrix of state-dependent probabilities/ density values of dimension c(n, N)
delta = c(0.5, 0.5) Gamma = matrix(c(0.9, 0.1, 0.2, 0.8), nrow = 2, byrow = TRUE) allprobs = matrix(runif(200), nrow = 100, ncol = 2) states = viterbi(delta, Gamma, allprobs)
Run the code above in your browser using DataLab