View source: R/decoding_functions.R
viterbi | R Documentation |
The Viterbi algorithm allows one to decode the most probable state sequence of an HMM.
viterbi(delta, Gamma, allprobs, trackID = NULL, mod = NULL)
delta |
initial distribution of length N, or matrix of dimension c(k,N) for k independent tracks, if |
Gamma |
transition probability matrix of dimension c(N,N) or array of transition probability matrices of dimension c(N,N,k) if |
allprobs |
matrix of state-dependent probabilities/ density values of dimension c(n, N) |
trackID |
optional vector of k track IDs, if multiple tracks need to be decoded separately |
mod |
optional model object containing initial distribution If you are using automatic differentiation either with |
vector of decoded states of length n
Other decoding functions:
stateprobs()
,
stateprobs_g()
,
stateprobs_p()
,
viterbi_g()
,
viterbi_p()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.