hmmgenerate
statistics: [sequence, states] = hmmgenerate (len, transprob, outprob)
statistics: […] = hmmgenerate (…, "symbols", symbols)
statistics: […] = hmmgenerate (…, "statenames", statenames)
Output sequence and hidden states of a hidden Markov model.
Generate an output sequence and hidden states of a hidden Markov model.
The model starts in state 1 at step 0 but will not include
step 0 in the generated states and sequence.
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 (outprob).
1 to
columns (transprob).
If "symbols" is specified, then the elements of symbols are
used for the output sequence 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 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)
symbols = {"A", "B", "C"};
statenames = {"One", "Two"};
[sequence, states] = hmmgenerate (25, transprob, outprob, ...
"symbols", symbols, ...
"statenames", statenames)
|
Source Code: hmmgenerate
Generate an output sequence and its hidden states from a two-state model (a fair and a loaded die).
transprob = [0.95, 0.05; 0.10, 0.90];
outprob = [1/6, 1/6, 1/6, 1/6, 1/6, 1/6; 1/10, 1/10, 1/10, 1/10, 1/10, 1/2];
[sequence, states] = hmmgenerate (15, transprob, outprob, ...
"statenames", {"fair", "loaded"})
sequence =
3 1 2 4 4 4 1 4 2 2 2 4 2 6 6
states =
1x15 cell array
Columns 1 through 10:
{'fair'} {'fair'} {'fair'} {'fair'} {'fair'} {'fair'} {'fair'} {'loaded'} {'loaded'} {'loaded'}
Columns 11 through 15:
{'loaded'} {'loaded'} {'loaded'} {'loaded'} {'loaded'}