[ESTTR,ESTEMIT] = hmmtrain(seq,TRGUESS,EMITGUESS)
estimatesthe transition and emission probabilities for a hidden Markov modelusing the Baum-Welch algorithm. seq
can be a rowvector containing a single sequence, a matrix with one row per sequence,or a cell array with each cell containing a sequence. TRGUESS
and EMITGUESS
areinitial estimates of the transition and emission probability matrices. TRGUESS(i,j)
isthe estimated probability of transition from state i
tostate j
. EMITGUESS(i,k)
is theestimated probability that symbol k
is emittedfrom state i
. hmmtrain(...,'Algorithm',algorithm
)
specifiesthe training algorithm. algorithm
can beeither 'BaumWelch'
or 'Viterbi'
.The default algorithm is 'BaumWelch'
.hmmtrain(...,'Symbols',SYMBOLS)
specifies the symbols that are emitted. SYMBOLS
can be a numeric array, a string array, or a cell array of the names of the symbols. The default symbols are integers 1
through N
, where N
is the number of possible emissions.hmmtrain(...,'Tolerance',tol)
specifiesthe tolerance used for testing convergence of the iterative estimationprocess. The default tolerance is 1e-4
.hmmtrain(...,'Maxiterations',maxiter)
specifiesthe maximum number of iterations for the estimation process. The defaultmaximum is 100
.hmmtrain(...,'Verbose',true)
returns thestatus of the algorithm at each iteration.hmmtrain(...,'Pseudoemissions',PSEUDOE)
specifiespseudocount emission values for the Viterbi training algorithm. Usethis argument to avoid zero probability estimates for emissions withvery low probability that might not be represented in the sample sequence. PSEUDOE
shouldbe a matrix of size m-by-n,where m is the number of states in the hidden Markovmodel and n is the number of possible emissions.If the i→k emission doesnot occur in seq
, you can set PSEUDOE(i,k)
tobe a positive number representing an estimate of the expected numberof such emissions in the sequence seq
.hmmtrain(...,'Pseudotransitions',PSEUDOTR)
specifiespseudocount transition values for the Viterbi training algorithm.Use this argument to avoid zero probability estimates for transitionswith very low probability that might not be represented in the samplesequence. PSEUDOTR
should be a matrix of size m-by-m,where m is the number of states in the hidden Markovmodel. If the i→j transitiondoes not occur in states
, you can set PSEUDOTR(i,j)
tobe a positive number representing an estimate of the expected numberof such transitions in the sequence states
.hmmestimate
toestimate the model parameters.tolerance'
controls howmany steps the hmmtrain
algorithm executes beforethe function returns an answer. The algorithm terminates when allof the following three quantities are less than the value that youspecify for tolerance
:seq
isgenerated by the currently estimated values of the transition andemission matrices 'tolerance'
is 1e-6
.Increasing the tolerance decreases the number of steps the hmmtrain
algorithmexecutes before it terminates.maxiterations
'maxiterations'
,controls the maximum number of steps the algorithm executes beforeit terminates. If the algorithm executes maxiter
iterationsbefore reaching the specified tolerance, the algorithm terminatesand the function returns a warning. If this occurs, you can increasethe value of 'maxiterations'
to make the algorithmreach the desired tolerance before terminating.