represents a discrete-time, finite-state hidden Markov process with transition matrix m, emission matrix em, and initial hidden state i0.


represents a hidden Markov process with emission distributions disti.


represents a hidden Markov process with initial hidden state probability vector p0.


  • HiddenMarkovProcess is also known as a hidden Markov model or HMM.
  • HiddenMarkovProcess is a discrete-time and discrete-state random process.
  • A hidden Markov process has DiscreteMarkovProcess[p0,m] as an underlying hidden state transition process. The values observed from a hidden Markov process, called emissions, are random and follow emission distributions disti at state i. Emissions produced while visiting a given sequence of states are independent.
  • The hidden states of HiddenMarkovProcess are integers between 1 and , where is the length of the transition matrix m.
  • The transition matrix m specifies conditional hidden state transition probabilities mi,jProbability[x[k+1]jx[k]i], where x[k] is the hidden state of the process at time k.
  • The emission matrix em specifies the probabilities for emissions at a given hidden state emi,rProbability[y[k]rx[k]i], where x[k] is the hidden state and y[k] is the emission at time k.
  • The emission distributions disti must be all univariate or all multivariate, all discrete or all continuous.
  • The emission distribution disti specifies that y[k]disti, given that x[k]i.
  • A silent state that produces no emissions is represented by a row of zeros in the case of an emission matrix or by None for general emissions. Each silent state must have a path to an emitting state.
  • For a hidden Markov process proc with silent states, HiddenMarkovProcess[proc] gives the effective process with silent states removed.
  • EstimatedProcess[data,HiddenMarkovProcess[n,edist]] can be used to estimate an n state process with emission distributions in the family specified by edist.
  • The following special edist templates can be used:
  • ss discrete emissions
    "Gaussian"Gaussian emissions
    distemissions for all states distributed as dist
    {dist1,,distn}emission distribution disti from state i
  • EstimatedProcess accepts the following settings for ProcessEstimator:
  • Automaticautomatically choose the parameter estimator
    "BaumWelch"maximize log-likelihood by expectation maximization
    "ViterbiTraining"decode most likely path and use supervised training
    "StateClustering"use clustering followed by supervised training
    "SupervisedTraining"estimation using both state and emission data
  • The methods "BaumWelch", "ViterbiTraining", and "StateClustering" do not require specifying the hidden state path in the estimation, whereas "SupervisedTraining" relies on having access to the hidden state path data.
  • Functions that work on data such as LogLikelihood accept Missing values.
  • RandomFunction[HiddenMarkovProcess[]] gives only emissions by default. With Method->{"IncludeHiddenStates"->True}, it gives a TemporalData object td with the state sequence included as metadata. The hidden state data can be retrieved using td["HiddenStates"].
  • HiddenMarkovProcess allows m to be an × matrix with non-negative elements and rows that sum to 1, em an × matrix with non-negative elements and rows that sum to 0 or 1, i0 an integer between 1 and , and p0 a vector of length of non-negative elements that sum to 1.
  • HiddenMarkovProcess can be used with such functions as LogLikelihood, FindHiddenMarkovStates, EstimatedProcess, PDF, Probability, and RandomFunction.


open all close all

Basic Examples  (2)

Define a hidden Markov process:

Click for copyable input

Simulate it:

Click for copyable input

Visualize the emissions:

Click for copyable input

Find the most likely hidden state sequence (Viterbi decode) from the given emissions:

Click for copyable input
Click for copyable input

Scope  (17)

Generalizations & Extensions  (1)

Applications  (11)

Properties & Relations  (6)

Possible Issues  (5)

Introduced in 2014