### Function Reference: `hmmestimate`

statistics: [transprobest, outprobest] = hmmestimate (sequence, states)
statistics: […] = hmmestimate (…, `"statenames"`, statenames)
statistics: […] = hmmestimate (…, `"symbols"`, symbols)
statistics: […] = hmmestimate (…, `"pseudotransitions"`, pseudotransitions)
statistics: […] = hmmestimate (…, `"pseudoemissions"`, pseudoemissions)

Estimation of a hidden Markov model for a given sequence.

Estimate the matrix of transition probabilities and the matrix of output probabilities of a given sequence of outputs and states generated by a hidden Markov model. 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.

### Arguments

- sequence is a vector of a sequence of given outputs. The outputs must be integers ranging from `1` to the number of outputs of the hidden Markov model.
- states is a vector of the same length as sequence of given states. The states must be integers ranging from `1` to the number of states of the hidden Markov model.

### Return values

- transprobest is the matrix of the estimated transition probabilities of the states. `transprobest(i, j)` is the estimated probability of a transition to state `j` given state `i`.
- outprobest is the matrix of the estimated output probabilities. `outprobest(i, j)` is the estimated probability of generating output `j` given state `i`.

If `'symbols'` is specified, then sequence is expected to be a sequence of the elements of symbols instead of integers. symbols can be a cell array.

If `'statenames'` is specified, then states is expected to be a sequence of the elements of statenames instead of integers. statenames can be a cell array.

If `'pseudotransitions'` is specified then the integer matrix pseudotransitions is used as an initial number of counted transitions. `pseudotransitions(i, j)` is the initial number of counted transitions from state `i` to state `j`. transprobest will have the same size as pseudotransitions. Use this if you have transitions that are very unlikely to occur.

If `'pseudoemissions'` is specified then the integer matrix pseudoemissions is used as an initial number of counted outputs. `pseudoemissions(i, j)` is the initial number of counted outputs `j` given state `i`. If `'pseudoemissions'` is also specified then the number of rows of pseudoemissions must be the same as the number of rows of pseudotransitions. outprobest will have the same size as pseudoemissions. Use this if you have outputs or states that are very unlikely to occur.

### Examples

     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);
     [transprobest, outprobest] = hmmestimate (sequence, states)
     symbols = {"A", "B", "C"};
     statenames = {"One", "Two"};
     [sequence, states] = hmmgenerate (25, transprob, outprob, ...
                                       "symbols", symbols, ...
                                       "statenames", statenames);
     [transprobest, outprobest] = hmmestimate (sequence, states, ...
                                       "symbols', symbols, ...
                                       "statenames', statenames)
     pseudotransitions = [8, 2; 4, 6];
     pseudoemissions = [2, 4, 4; 7, 2, 1];
     [sequence, states] = hmmgenerate (25, transprob, outprob);
     [transprobest, outprobest] = hmmestimate (sequence, states, ...
                                  "pseudotransitions", pseudotransitions, ...
                                  "pseudoemissions", pseudoemissions)

### References

1. Wendy L. Martinez and Angel R. Martinez. Computational Statistics Handbook with MATLAB. Appendix E, pages 547-557, Chapman & Hall/CRC, 2001.
2. Lawrence R. Rabiner. A Tutorial on Hidden Markov Models and Selected Applications in Speech Recognition. Proceedings of the IEEE, 77(2), pages 257-286, February 1989.

Source Code: hmmestimate