Use the Viterbi algorithm to find the Viterbi path of a hidden Markov
model given a sequence of outputs. The model assumes that the generation
starts in state 1
at step 0
but does not include step
0
in the generated states and sequence.
1
to
columns (outprob)
.
transprob(i, j)
is the probability of a transition to state
j
given state i
.
outprob(i, j)
is the probability of generating output j
given state i
.
1
to
columns (transprob)
.
If 'symbols'
is specified, then sequence is expected to be a
sequence of the elements of symbols instead of integers ranging
from 1
to columns (outprob)
. symbols can be a cell array.
If 'statenames'
is specified, then the elements of
statenames are used for the states in vpath instead of
integers ranging from 1
to columns (transprob)
.
statenames can be a cell array.
transprob = [0.8, 0.2; 0.4, 0.6]; outprob = [0.2, 0.4, 0.4; 0.7, 0.2, 0.1]; [sequence, states] = hmmgenerate (25, transprob, outprob) vpath = hmmviterbi (sequence, transprob, outprob)
symbols = {'A', 'B', 'C'}; statenames = {'One', 'Two'}; [sequence, states] = hmmgenerate (25, transprob, outprob, 'symbols', symbols, 'statenames', statenames) vpath = hmmviterbi (sequence, transprob, outprob, 'symbols', symbols, 'statenames', statenames)
Package: statistics