Mercurial > forge
comparison main/statistics/inst/hmmgenerate.m @ 2689:e8b0cde34d1b octave-forge
Improved texinfo.
author | whyly |
---|---|
date | Sun, 15 Oct 2006 19:50:42 +0000 |
parents | a613a7093388 |
children | 762ed030be30 |
comparison
equal
deleted
inserted
replaced
2688:a52a009b4908 | 2689:e8b0cde34d1b |
---|---|
17 ## -*- texinfo -*- | 17 ## -*- texinfo -*- |
18 ## @deftypefn {Function File} {[@var{sequence}, @var{states}] =} hmmgenerate (@var{len}, @var{transprob}, @var{outprob}) | 18 ## @deftypefn {Function File} {[@var{sequence}, @var{states}] =} hmmgenerate (@var{len}, @var{transprob}, @var{outprob}) |
19 ## @deftypefnx {Function File} {} hmmgenerate (@dots{}, 'symbols', @var{symbols}) | 19 ## @deftypefnx {Function File} {} hmmgenerate (@dots{}, 'symbols', @var{symbols}) |
20 ## @deftypefnx {Function File} {} hmmgenerate (@dots{}, 'statenames', @var{statenames}) | 20 ## @deftypefnx {Function File} {} hmmgenerate (@dots{}, 'statenames', @var{statenames}) |
21 ## Generates an output sequence and hidden states for a Hidden Markov Model. | 21 ## Generates an output sequence and hidden states for a Hidden Markov Model. |
22 ## The model starts with state @code{1} at step @code{0} but will not | 22 ## The model starts in state @code{1} at step @code{0} but will not include |
23 ## include step @code{0} in the generated states and sequence | 23 ## step @code{0} in the generated states and sequence. |
24 ## | 24 ## |
25 ## Arguments are | 25 ## Arguments are |
26 ## | 26 ## |
27 ## @itemize | 27 ## @itemize @bullet |
28 ## @item | 28 ## @item |
29 ## @var{len} is the number of steps to generate. @var{sequence} and | 29 ## @var{len} is the number of steps to generate. @var{sequence} and |
30 ## @var{states} will have @var{len} entries each | 30 ## @var{states} will have @var{len} entries each. |
31 ## @item | 31 ## |
32 ## @var{transprob} is the matrix with the transition probabilities for the | 32 ## @item |
33 ## states. @code{transprob (i, j)} is the probability for a transition to | 33 ## @var{transprob} is the matrix of transition probabilities for the states. |
34 ## state @code{j} given state @code{i} | 34 ## @code{transprob (i, j)} is the probability for a transition to state |
35 ## @item | 35 ## @code{j} given state @code{i}. |
36 ## @var{outprob} is the matrix with the output probabilities. | 36 ## |
37 ## @item | |
38 ## @var{outprob} is the matrix of output probabilities. | |
37 ## @code{outprob (i, j)} is the probability for generating output @code{j} | 39 ## @code{outprob (i, j)} is the probability for generating output @code{j} |
38 ## given state @code{i} | 40 ## given state @code{i}. |
39 ## @end itemize | 41 ## @end itemize |
40 ## | 42 ## |
41 ## Return values are | 43 ## Return values are |
42 ## | 44 ## |
43 ## @itemize | 45 ## @itemize @bullet |
44 ## @item | 46 ## @item |
45 ## @var{sequence} is a vector of length @var{len} with the generated | 47 ## @var{sequence} is a vector of length @var{len} of the generated |
46 ## outputs. The outputs are integers ranging from @code{1} to | 48 ## outputs. The outputs are integers ranging from @code{1} to |
47 ## @code{columns (outprob)} | 49 ## @code{columns (outprob)}. |
48 ## @item | 50 ## |
49 ## @var{states} is a vector of length @var{len} with the generated hidden | 51 ## @item |
52 ## @var{states} is a vector of length @var{len} of the generated hidden | |
50 ## states. The states are integers ranging from @code{1} to | 53 ## states. The states are integers ranging from @code{1} to |
51 ## @code{columns (transprob)} | 54 ## @code{columns (transprob)}. |
52 ## @end itemize | 55 ## @end itemize |
53 ## | 56 ## |
54 ## If 'symbols' is specified, then the elements of @var{symbols} are used | 57 ## If @code{'symbols'} is specified, then the elements of @var{symbols} are |
55 ## for the output sequence instead of integers ranging from @code{1} to | 58 ## used for the output sequence instead of integers ranging from @code{1} to |
56 ## @code{columns (outprob)}. @var{symbols} can be a cell array | 59 ## @code{columns (outprob)}. @var{symbols} can be a cell array. |
57 ## | 60 ## |
58 ## If 'statenames' is specified, then the elements of @var{statenames} are | 61 ## If @code{'statenames'} is specified, then the elements of |
59 ## used for the states instead of integers ranging from @code{1} to | 62 ## @var{statenames} are used for the states instead of integers ranging from |
60 ## @code{columns (transprob)}. @var{statenames} can be a cell array | 63 ## @code{1} to @code{columns (transprob)}. @var{statenames} can be a cell |
64 ## array. | |
61 ## | 65 ## |
62 ## Examples: | 66 ## Examples: |
63 ## | 67 ## |
64 ## @example | 68 ## @example |
69 ## @group | |
65 ## transprob = [0.8, 0.2; 0.4, 0.6]; | 70 ## transprob = [0.8, 0.2; 0.4, 0.6]; |
66 ## outprob = [0.2, 0.4, 0.4; 0.7, 0.2, 0.1]; | 71 ## outprob = [0.2, 0.4, 0.4; 0.7, 0.2, 0.1]; |
67 ## [sequence, states] = hmmgenerate (25, transprob, outprob) | 72 ## [sequence, states] = hmmgenerate (25, transprob, outprob) |
68 ## | 73 ## @end group |
74 ## | |
75 ## @group | |
69 ## symbols = @{'A', 'B', 'C'@}; | 76 ## symbols = @{'A', 'B', 'C'@}; |
70 ## statenames = @{'One', 'Two'@}; | 77 ## statenames = @{'One', 'Two'@}; |
71 ## [sequence, states] = hmmgenerate (25, transprob, outprob, 'symbols', symbols, 'statenames', statenames) | 78 ## [sequence, states] = hmmgenerate (25, transprob, outprob, 'symbols', symbols, 'statenames', statenames) |
79 ## @end group | |
72 ## @end example | 80 ## @end example |
73 ## | 81 ## |
74 ## References: | 82 ## References: |
75 ## | 83 ## |
76 ## @itemize | 84 ## @enumerate |
77 ## @item | 85 ## @item |
78 ## @cite{Matlab 7.0 documentation (pdf)} | 86 ## W. L. Martinez and A. R. Martinez. @cite{Computational Statistics |
79 ## @item | 87 ## Handbook with MATLAB.} Chapman & Hall/CRC, pages 547-557, 2001. |
80 ## @uref{http://en.wikipedia.org/wiki/Hidden_Markov_Model} | 88 ## |
81 ## @end itemize | 89 ## @item |
82 ## | 90 ## Wikipedia contributors. Hidden Markov model. @cite{Wikipedia, The Free |
91 ## Encyclopedia.} | |
92 ## @uref{http://en.wikipedia.org/w/index.php?title=Hidden_Markov_model&oldid=81100294}, | |
93 ## October 2006. | |
94 ## @end enumerate | |
83 ## @end deftypefn | 95 ## @end deftypefn |
84 | 96 |
85 ## Author: Arno Onken <whyly@gmx.net> | 97 ## Author: Arno Onken <whyly@gmx.net> |
98 ## Description: Output sequence and hidden states for a Hidden Markov Model | |
86 | 99 |
87 function [sequence, states] = hmmgenerate (len, transprob, outprob, varargin) | 100 function [sequence, states] = hmmgenerate (len, transprob, outprob, varargin) |
88 | 101 |
89 # Usage string | 102 # Usage string |
90 ustring = "[sequence, states] = hmmgenerate (len, transprob, outprob [, 'symbols', symbols] [, 'statenames', statenames])"; | 103 ustring = "[sequence, states] = hmmgenerate (len, transprob, outprob [, 'symbols', symbols] [, 'statenames', statenames])"; |