View source: R/decoding_functions.R
viterbi_p | R Documentation |
The Viterbi algorithm allows one to decode the most probable state sequence of an HMM.
viterbi_p(delta, Gamma, allprobs, tod, trackID = NULL, mod = NULL)
delta |
initial distribution of length N, or matrix of dimension c(k,N) for k independent tracks, if This could e.g. be the periodically stationary distribution (for each track). |
Gamma |
array of transition probability matrices for each time point in the cycle of dimension c(N,N,L), where L is the length of the cycle |
allprobs |
matrix of state-dependent probabilities/ density values of dimension c(n, N) |
tod |
(Integer valued) variable for cycle indexing in 1, ..., L, mapping the data index to a generalised time of day (length n) For half-hourly data L = 48. It could, however, also be day of year for daily data and L = 365. |
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()
,
viterbi_g()
delta = c(0.5, 0.5)
beta = matrix(c(-2, 1, -1,
-2, -1, 1), nrow = 2, byrow = TRUE)
Gamma = tpm_p(1:24, 24, beta)
tod = rep(1:24, 5)
n = length(tod)
allprobs = matrix(runif(2*n), nrow = n, ncol = 2)
states = viterbi_p(delta, Gamma, allprobs, tod)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.