{
  "id": "hidden-markov-model",
  "title": "Hidden Markov model",
  "lang": "en",
  "source_lang": "en",
  "summary": "A probabilistic model of sequential observations generated by unobserved states that evolve according to a Markov chain.",
  "category": "mathematics",
  "subcategory": "probability-statistics",
  "type": "concept",
  "aliases": [
    "HMM",
    "hidden Markov chain model"
  ],
  "generated_at": "2026-10-03",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/hidden-markov-model/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/hidden-markov-model/",
      "json": "https://aiwiki.page/zh/hidden-markov-model.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "A hidden Markov model (HMM) is a statistical model for sequential data in which an unobserved sequence of states generates observable outputs. The hidden states follow a Markov chain, while each observation is drawn from a distribution associated with its current state. An HMM therefore describes both how an underlying system changes and how those changes produce measurements. It is used in statistics, machine learning, and time-series analysis when the underlying states cannot be observed directly. (cs.ubc.ca)"
    },
    {
      "heading": "Mathematical structure",
      "text": "In the standard finite-state, discrete-time HMM, the hidden random variable \\(Z_t\\) takes one of \\(K\\) possible values, and \\(X_t\\) denotes the observation at position \\(t\\). The hidden sequence is a stochastic process satisfying the first-order Markov assumption:\n\n\\[P(Z_t\\mid Z_1,\\ldots,Z_{t-1}) =P(Z_t\\mid Z_{t-1}).\\]\n\nThe observation assumption is conditional independence: given the complete hidden sequence, observations are independent, and the distribution of \\(X_t\\) depends only on \\(Z_t\\). These assumptions concern the hidden process and conditional observations; the observed sequence itself need not be a first-order Markov chain. (web.stanford.edu)\n\nA time-homogeneous model has three principal components:\n\n- Initial distribution: \\(\\pi_i=P(Z_1=i)\\).\n- Transition matrix: \\(a_{ij}=P(Z_{t+1}=j\\mid Z_t=i)\\).\n- Emission distributions: \\(b_i(x)=p(X_t=x\\mid Z_t=i)\\).\n\nEach transition row sums to one. Emissions may describe discrete symbols, continuous measurements, or vectors. Continuous emissions can use a normal distribution or a Gaussian mixture model; in that case, \\(b_i(x)\\) denotes a density rather than a point probability. (cs.ubc.ca)\n\nFor parameters \\(\\theta\\), the joint distribution factors as\n\n\\[p(z_{1:T},x_{1:T}\\mid\\theta) =\\pi_{z_1}b_{z_1}(x_1) \\prod_{t=2}^{T} a_{z_{t-1},z_t}b_{z_t}(x_t).\\]\n\nThis makes an HMM a generative model: it specifies how to generate both states and observations. Its dependency structure can also be represented as a chain-structured Bayesian network. (web.stanford.edu)"
    },
    {
      "heading": "Inference and decoding",
      "text": "Three classical computational problems are distinguished: evaluating an observation sequence, estimating its hidden states, and learning model parameters. Directly enumerating all \\(K^T\\) state sequences is generally impractical. The chain structure instead permits efficient dynamic programming. (cs.ubc.ca)\n\nThe forward algorithm computes the observation likelihood by summing over hidden paths. Define\n\\(\\alpha_t(j)=p(x_{1:t},Z_t=j\\mid\\theta)\\). Then\n\n\\[\\alpha_1(j)=\\pi_jb_j(x_1), \\qquad \\alpha_t(j)=b_j(x_t)\\sum_i\\alpha_{t-1}(i)a_{ij}.\\]\n\nThe likelihood is \\(\\sum_j\\alpha_T(j)\\). For a dense transition matrix, the recursion requires \\(O(TK^2)\\) time, excluding emission-evaluation costs. Scaling intermediate quantities or using logarithmic arithmetic prevents numerical underflow in long sequences. (cs.ubc.ca)\n\nThe forward–backward algorithm combines forward quantities with backward quantities describing subsequent observations. It yields posterior state probabilities \\(P(Z_t=j\\mid x_{1:T})\\). Filtering conditions on observations available up to the current position; smoothing also incorporates later observations. Both quantify uncertainty rather than selecting only one state path. (cs.ubc.ca)\n\nThe Viterbi algorithm instead finds the single most probable complete hidden-state sequence. It replaces summation with maximization and stores predecessor choices for traceback. This global decoding differs from independently selecting the most probable state at each position: marginal choices need not form the most probable path and can even violate transition constraints. (web.stanford.edu)"
    },
    {
      "heading": "Parameter estimation",
      "text": "When hidden-state labels accompany the training data, supervised learning can estimate discrete transition and emission probabilities from normalized counts. When only observations are available, unsupervised learning commonly uses the Baum–Welch algorithm, an HMM-specific form of the expectation–maximization algorithm. (web.stanford.edu)\n\nIn its expectation step, forward–backward inference computes expected state occupancies and transition counts. Its maximization step updates parameters using these expectations. Under exact updates, the observed-data likelihood does not decrease, but maximum likelihood estimation can reach a local rather than global optimum. Initialization consequently affects the fitted result. For continuous emissions, updates also estimate the parameters of the chosen density family. (cs.ubc.ca)"
    },
    {
      "heading": "Applications",
      "text": "In speech recognition, HMM states can represent stages of speech sounds, with acoustic feature vectors serving as observations. Left-to-right transition structures encode progression through a sound while allowing variable duration through self-transitions. This separates sequential organization from the statistical description of acoustic measurements. (cs.ubc.ca)\n\nIn natural language processing, an HMM can treat grammatical categories as hidden states and words as observations. In biological sequence analysis, profile HMMs describe position-specific sequence patterns, using match, insertion, and deletion states to represent conserved positions and gaps. They support searches for related protein and DNA sequences. Here, the sequence index represents position rather than elapsed time. (web.stanford.edu)"
    },
    {
      "heading": "Assumptions and extensions",
      "text": "A standard HMM summarizes the relevant hidden history through its current state and assumes conditionally independent emissions. These restrictions can be inadequate when observations retain dependencies not explained by that state. State-space design and emission distributions therefore determine which structure the model can represent. (cs.ubc.ca)\n\nFor a nonabsorbing state \\(i\\), a constant self-transition probability implies a geometrically distributed uninterrupted residence time:\n\n\\[P(D=d)=a_{ii}^{d-1}(1-a_{ii}),\\qquad d\\geq1.\\]\n\nThe hidden semi-Markov model replaces this implicit duration mechanism with explicit duration distributions. It can represent residence times whose probability of ending depends on how long the system has already occupied the state, while retaining a hidden-state description of sequential observations. (cs.ubc.ca)"
    }
  ],
  "links": [
    "markov-chain",
    "statistics",
    "machine-learning",
    "time-series",
    "random-variable",
    "stochastic-process",
    "conditional-independence",
    "matrix",
    "normal-distribution",
    "gaussian-mixture-model",
    "probability",
    "bayesian-network",
    "dynamic-programming",
    "training-data",
    "supervised-learning",
    "unsupervised-learning",
    "expectation-maximization-algorithm",
    "maximum-likelihood-estimation",
    "speech-recognition",
    "natural-language-processing",
    "protein",
    "dna"
  ],
  "sources": [
    {
      "title": "cs.ubc.ca/~murphyk/Bayes/hmm.17jan01.html",
      "url": "https://www.cs.ubc.ca/~murphyk/Bayes/hmm.17jan01.html"
    },
    {
      "title": "web.stanford.edu/~jurafsky/slp3/A.pdf",
      "url": "https://web.stanford.edu/~jurafsky/slp3/A.pdf"
    },
    {
      "title": "cs.ubc.ca/~murphyk/Bayes/rabiner.pdf",
      "url": "https://www.cs.ubc.ca/~murphyk/Bayes/rabiner.pdf"
    },
    {
      "title": "cs.ubc.ca/~murphyk/Teaching/CS540-Spring10/projects/Yu-hsmm09.pdf",
      "url": "https://www.cs.ubc.ca/~murphyk/Teaching/CS540-Spring10/projects/Yu-hsmm09.pdf"
    }
  ],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}