---
title: Hidden Markov Model Explanation | Definition
url: https://www.emergentmind.com/topics/hidden-markov-model
type: topic
---

# Hidden Markov Model Explanation | Definition

A **hidden Markov model (HMM)** is a probabilistic model for sequential data in which an unobserved state sequence evolves as a Markov chain and generates observed variables through state-conditioned distributions. For a finite model with hidden states $Q_t\in\{1,\ldots,N\}$ and observations $O_t\in\{V_1,\ldots,V_M\}$, the parameterization is conventionally $\lambda=(\pi,A,B)$, comprising an initial-state distribution $\pi$, a transition matrix $A$, and an emission model $B$. The defining assumptions are that the current hidden state depends only on the preceding hidden state and that the current observation depends only on the current hidden state. HMMs support likelihood evaluation, latent-state decoding, filtering, smoothing, and parameter learning, and have been applied to speech recognition, natural language processing, gesture recognition, gene sequencing, physical measurement, medical monitoring, financial regime detection, cybersecurity, coding, and distributed state estimation [1102.0899; 1206.0500; 2401.14669].

## 1. Probabilistic structure and assumptions

Let $Q=(Q_1,\ldots,Q_T)$ denote the hidden sequence and $O=(O_1,\ldots,O_T)$ the observed sequence. The initial-state probabilities are

$$
\pi_i=P(Q_1=i),\qquad \sum_{i=1}^{N}\pi_i=1.
$$

The hidden-state transition probabilities are

$$
a_{ij}=P(Q_{t+1}=j\mid Q_t=i),
$$

with

$$
\sum_{j=1}^{N}a_{ij}=1
$$

for every $i$. The emission probabilities for a discrete alphabet are

$$
b_j(h)=P(O_t=V_h\mid Q_t=j),
$$

with

$$
\sum_{h=1}^{M}b_j(h)=1.
$$

The standard HMM assumptions are

$$
P(Q_t\mid Q_1,\ldots,Q_{t-1})=P(Q_t\mid Q_{t-1})
$$

and

$$
P(O_t\mid Q_1,\ldots,Q_T,O_1,\ldots,O_{t-1})=P(O_t\mid Q_t).
$$

Thus, conditional on the current hidden state, the current observation is independent of other observations and hidden states. The resulting joint probability is

$$
P(O,Q\mid\lambda)
=
\pi_{Q_1}b_{Q_1}(O_1)
\prod_{t=1}^{T-1}
a_{Q_tQ_{t+1}}b_{Q_{t+1}}(O_{t+1}).
$$

The observable likelihood is obtained by summing over all hidden paths:

$$
P(O\mid\lambda)=\sum_Q P(O,Q\mid\lambda).
$$

This marginalization is nonlinear in the model parameters because the hidden sequence is unobserved. In a time-homogeneous HMM, $A$ and $B$ do not depend on $t$; the initial distribution need not be an equilibrium distribution. In the categorical formulation, the hidden states form a Markov chain and observation kernels attach to the current hidden state. The same factorization can be expressed in Markov categories, where stochastic kernels, conditionals, copying, marginalization, and conditional independence provide an abstract representation applicable to discrete probability, Gaussian probability, measure-theoretic probability, and possibilistic nondeterminism [2401.14669].

The three classical HMM problems are:

1. **Evaluation**: compute $P(O\mid\lambda)$.
2. **Decoding**: determine the most probable hidden-state sequence.
3. **Learning**: estimate $\lambda$ to maximize the observation likelihood.

The Markov assumptions are modeling assumptions rather than universal properties of sequential data. Several extensions relax them by introducing observation history, higher-order state dependence, time-varying transition laws, structured multivariate latent processes, or recurrent covariate-dependent persistence.

## 2. Inference and decoding

The forward variable

$$
\alpha_i(t)=P(O_1,\ldots,O_t,Q_t=i\mid\lambda)
$$

is initialized by

$$
\alpha_i(1)=\pi_i b_i(O_1)
$$

and recursively updated by

$$
\alpha_j(t+1)
=
\left[\sum_{i=1}^{N}\alpha_i(t)a_{ij}\right]b_j(O_{t+1}).
$$

The likelihood is

$$
P(O\mid\lambda)=\sum_{i=1}^{N}\alpha_i(T).
$$

The forward algorithm avoids explicit enumeration of the $N^T$ possible hidden paths and requires $O(TN^2)$ time for a dense discrete HMM. The backward variable is

$$
\beta_i(t)=P(O_{t+1},\ldots,O_T\mid Q_t=i,\lambda),
$$

with

$$
\beta_i(T)=1
$$

and

$$
\beta_i(t)=
\sum_{j=1}^{N}
a_{ij}b_j(O_{t+1})\beta_j(t+1).
$$

Forward and backward variables yield the smoothed state posterior

$$
\gamma_i(t)=P(Q_t=i\mid O,\lambda)
=
\frac{\alpha_i(t)\beta_i(t)}
{\sum_{j=1}^{N}\alpha_j(t)\beta_j(t)}.
$$

They also yield the pairwise transition posterior

$$
\xi_{ij}(t)
=
P(Q_t=i,Q_{t+1}=j\mid O,\lambda)
$$

with numerator

$$
\alpha_i(t)a_{ij}b_j(O_{t+1})\beta_j(t+1).
$$

For online inference, the filtering distribution is updated through prediction and correction. The prediction propagates the previous posterior through $A$; the correction multiplies the predicted state probabilities by the observation likelihood and normalizes. This is the discrete form of the Bayes filter. In the categorical framework, the same construction specializes to the Kalman filter in Gaussian probability and to nondeterministic state propagation in possibilistic models [2401.14669].

The Viterbi algorithm replaces summation over paths with maximization. Its dynamic-programming variable is

$$
\delta_t(j)
=
\max_{Q_1,\ldots,Q_{t-1}}
P(Q_1,\ldots,Q_t=j,O_1,\ldots,O_t\mid\lambda).
$$

The recursion is

$$
\delta_{t+1}(j)
=
\max_{1\leq i\leq N}
\left[
\delta_t(i)a_{ij}b_j(O_{t+1})
\right],
$$

and the maximizing predecessor is stored as

$$
\psi_{t+1}(j)
=
\arg\max_i
\left[\delta_t(i)a_{ij}\right].
$$

Backtracking from

$$
Q_T^*=\arg\max_i\delta_T(i)
$$

produces the most probable complete state path. Maximizing each state independently is not equivalent to maximizing the entire path; predecessor backpointers are required.

For long sequences, scaling or log-space computation is required to prevent underflow. Forward-backward inference also supplies the sufficient statistics used by Baum–Welch and by many extensions, including time-varying, neural-emission, and structured multivariate HMMs.

## 3. Parameter learning and identifiability

Baum–Welch is an Expectation–Maximization procedure. The E-step computes $\gamma_i(t)$ and $\xi_{ij}(t)$ using forward-backward inference. The M-step updates

$$
\pi_i^{\mathrm{new}}=\gamma_i(1),
$$

$$
a_{ij}^{\mathrm{new}}
=
\frac{\sum_{t=1}^{T-1}\xi_{ij}(t)}
{\sum_{t=1}^{T-1}\gamma_i(t)},
$$

and, for discrete observations,

$$
b_j^{\mathrm{new}}(h)
=
\frac{
\sum_{t=1}^{T}\mathbf 1[O_t=V_h]\gamma_j(t)
}{
\sum_{t=1}^{T}\gamma_j(t)
}.
$$

Under the standard Baum–Welch argument,

$$
P(O\mid\lambda^{\mathrm{new}})
\geq
P(O\mid\lambda^{\mathrm{old}}).
$$

This monotonicity does not imply global optimality. The likelihood is generally non-convex, and EM can converge to a local maximum or stationary point depending on initialization, state number, parameter constraints, and data quality.

Finite HMMs also exhibit parameter non-identifiability. Hidden-state labels can be permuted without changing the observable distribution. For binary HMMs with binary hidden and visible variables, there are five free stochastic parameters: one in the initial distribution, two in the transition matrix, and two in the emission matrix. The observable model has dimension five, and generic ambiguity is principally hidden-state label swapping [1206.0500].

Algebraic statistics distinguishes the stochastic model from its algebraic closure. The model consists of distributions generated by valid nonnegative stochastic parameters; the associated variety is the Zariski or projective closure over complex parameters. Polynomial invariants characterize the variety but do not by themselves enforce nonnegativity or stochasticity. In the binary two-hidden-state case, a birational reparameterization $(a,b,c,u,v)$ provides rationally identifiable observable combinations, while the original parameters remain generically identifiable only up to hidden-label swapping. Exceptional lower-dimensional strata include an IID model when the hidden state has no effect on observations, an independent-but-not-identically-distributed submodel when hidden states do not influence one another, and an equilibrium submodel when the hidden chain is at equilibrium.

For four observed binary variables, the BHMM ideal is minimally generated by 21 homogeneous quadrics and 29 homogeneous cubics. These invariants extend to longer sequences by applying them to consecutive four-variable windows. A semialgebraic membership test must combine algebraic equalities, nonnegative observed probabilities, stochastic parameter reconstruction, and explicit treatment of exceptional parameter loci [1206.0500].

## 4. Extensions of the basic dependence structure

Several extensions retain dynamic programming while changing the conditional-independence structure.

### Observation-history models

The Evidence Feed Forward HMM adds a state-dependent observation-linkage factor $c_i(h,k)$, approximately

$$
c_i(h,k)\approx P(O_{t+1}=V_k\mid Q_t=i,O_t=V_h).
$$

Its parameterization is $\lambda=(\pi,A,B,C)$, with

$$
\sum_{k=1}^{M}c_i(h,k)=1.
$$

The local factorization becomes

$$
P(Q_{t+1}=j,O_{t+1}=V_k\mid Q_t=i,O_t=V_h)
=
a_{ij}b_j(k)c_i(h,k).
$$

The forward recursion is

$$
\alpha_j(t+1)
=
\sum_{i=1}^{N}
\alpha_i(t)a_{ij}b_j(O_{t+1})c_i(O_t,O_{t+1}).
$$

The leading inference complexity remains $O(TN^2)$, but storage increases by $NM^2$. The model is intended for cases in which local observation patterns, such as directional changes in motion, contain information not captured by state-wise emission probabilities [1102.0899].

The Markov Observation Model makes the observation sequence itself Markov conditional on the new hidden state:

$$
P(Y_{n+1}=y\mid X_{n+1}=x',Y_n=y_n)
=
q_{y_n\to y}(x').
$$

The pair $(X_n,Y_n)$ is jointly Markov, and the initial distribution is a joint distribution $\mu(x,y)$ rather than a distribution over the hidden state alone. The forward recursion becomes

$$
\alpha_n(x_n)
=
q_{Y_{n-1}\to Y_n}(x_n)
\sum_{x_{n-1}}
\alpha_{n-1}(x_{n-1})p_{x_{n-1}\to x_n}.
$$

The standard HMM is recovered when $q_{y\to y'}(x)=b_x(y')$. The corresponding EM algorithm estimates hidden transitions, observation transitions, and the initial joint distribution; filtering and Viterbi decoding retain the preceding observation as part of the recursion [2208.06368].

### Higher-order models

A second-order HMM replaces

$$
P(s_t\mid s_{1:t-1})
=
P(s_t\mid s_{t-1})
$$

with

$$
P(s_t\mid s_{1:t-1})
=
P(s_t\mid s_{t-2},s_{t-1}).
$$

The transition parameter is

$$
a_{ijk}=P(s_k^t\mid s_i^{t-2},s_j^{t-1}).
$$

The dynamic-programming state must retain the previous pair:

$$
\alpha_t(j,k)
=
b_k(o_t)\sum_i\alpha_{t-1}(i,j)a_{ijk}.
$$

Inference therefore increases from $O(TN^2)$ to $O(TN^3)$. The second-order belief HMM replaces probabilities with basic belief assignments, allowing mass on subsets of the hidden-state frame to represent imprecision, ignorance, and conflicting evidence. It uses belief-function combination, commonality representations, and pignistic transformation, but the proposed second-order belief model has no completed empirical evaluation and leaves conflict normalization and full parameter learning incompletely specified [1501.05613].

### Multivariate and graphical HMMs

Multiple Hidden Markov Models use a multivariate latent Markov chain and multiple observed categorical processes. An unrestricted multivariate latent state is equivalent to an ordinary HMM whose state space is the Cartesian product of the latent state spaces, but structured graphical restrictions provide parsimonious interpretations of dynamic dependence, contemporaneous association, common latent effects, and series-specific effects.

Linked MHMMs allow latent blocks to depend on their own past and associate observed blocks with corresponding latent blocks. Coupled MHMMs make latent blocks conditionally independent given the complete previous latent vector. Graphical independencies translate into linear zero restrictions on marginal log-linear interactions, allowing tests of noncausality, contemporaneous independence, local independence, invariant association, and additive latent effects [1309.3895].

## 5. Nonstationary, recurrent, and nonparametric HMMs

A standard HMM assumes stationary transition and emission parameters. Several models relax this restriction.

An activity-driven HMM supplies known exogenous activity functions $f_j(t)$ and $g_j(t)$ that modulate transitions and emissions:

$$
a_{ij}(t)=f_j(t)\tau_{ij},\qquad i\neq j,
$$

$$
a_{jj}(t)
=
1-f_j(t)\sum_{i\neq j}\tau_{ij},
$$

and

$$
b_{sj}(t)=g_j(t)\epsilon_{sj},\qquad s\neq0,
$$

with a residual probability for the no-emission symbol. Forward-backward inference remains standard after replacing $A$ and $B$ by $A(t)$ and $B(t)$. The EM M-step changes because the intensities occur in both off-diagonal and residual terms; state-specific scalar monotone equations are solved numerically. The model becomes an ordinary stationary HMM when $f_j(t)\equiv1$ and $g_j(t)\equiv1$ [1507.07495].

The HMRNN embeds a conventional HMM into a recurrent neural network. Its recurrent computation exactly implements

$$
\boldsymbol{\alpha}_t
=
\boldsymbol{\alpha}_{t-1}
\mathbf P
\operatorname{diag}(\boldsymbol{\Psi}_{y_t}),
$$

so the unaugmented HMRNN has the same likelihood and parameter interpretations as the corresponding HMM. Covariate-dependent neural modules can instead produce individualized initial distributions or modify transitions and emissions. The model can be trained by gradient descent rather than EM, permitting joint optimization of HMM quantities, patient covariates, and auxiliary predictive objectives [2006.03151].

The recurrent sticky HDP-HMM combines Bayesian nonparametric state discovery with observation-dependent persistence. Its non-self transition distribution is drawn from an HDP, while the persistence probability is

$$
\kappa_{j,t+1}
=
\sigma(R_j^{T}y_t+r_j).
$$

The transition distribution is

$$
\pi_{j,t}
=
\kappa_{j,t}\delta_j+(1-\kappa_{j,t})\bar{\pi}_j.
$$

Pólya–Gamma augmentation provides conditionally Gaussian updates for the logistic persistence parameters. Weak-limit Gibbs sampling uses forward-backward state-sequence updates with complexity $O(TL^2)$ for $L$ approximating states. This model extends the disentangled sticky HDP-HMM, which independently controls transition-row similarity, mean self-persistence, and heterogeneity of persistence across states [2004.03019; 2411.04278].

The $\alpha\beta$-HMM specializes the transition matrix to equal exit probabilities:

$$
p_{mn}
=
\begin{cases}
1-(M-1)\alpha,&m=n,\\
\alpha,&m\neq n.
\end{cases}
$$

The filtering prediction becomes

$$
\pi_i(\theta_m)
=
(1-\alpha M)\mu_{i-1}(\theta_m)+\alpha.
$$

The scalar $\alpha$ controls the trade-off between retaining historical evidence and adapting to state changes. Small $\alpha$ yields greater stationary-environment accuracy but slower adaptation; larger $\alpha$ accelerates adaptation while producing a nonzero steady-state error floor. This model is standard HMM filtering under a restricted equal-exit transition structure rather than a general replacement for an arbitrary transition matrix [2504.01759].

## 6. Neural, algebraic, distributed, and application-specific HMMs

GenHMM replaces conventional state emissions with mixtures of normalizing-flow generators:

$$
p(\mathbf x\mid s)
=
\sum_{\kappa=1}^{K}
\pi_{s,\kappa}
p(\mathbf x\mid s,\kappa).
$$

Each generator is an invertible neural flow with exact density evaluation through the change-of-variables formula. The HMM forward-backward structure is unchanged; the additional latent generator index is handled through local responsibilities. EM updates the initial distribution, transition matrix, and generator-mixture weights in closed form, while flow parameters are optimized by stochastic gradient steps. The model preserves exact likelihood computation and was evaluated for phoneme classification on TIMIT, where it outperformed conventional GMM-HMM baselines in the reported experiments [1910.05744].

For language modeling, the very large neural HMM uses blocked emissions, neural parameterization, and state dropout. With $N$ latent states divided into blocks of size $k$, only the $k$ states associated with the observed word can emit that word, reducing exact serial inference from $O(TN^2)$ to $O(Tk^2)$. Neural embeddings and MLPs generate transition and emission scores rather than storing unconstrained parameter tables. On Penn Treebank and WikiText-2, the reported model improved over earlier HMM and n-gram systems but remained behind LSTM and AWD-LSTM baselines [2011.04640].

Distributed HMM filtering places local observations at network agents. Each agent propagates its belief through the transition matrix, performs a local Bayesian update, and combines neighboring beliefs through a logarithmic opinion pool. Under strong connectivity, bounded log-likelihoods, positive initialization, and geometric ergodicity, the asymptotic discrepancy from centralized filtering is bounded in expected KL divergence. The bound depends on transition mixing, graph mixing, network size, and the observation-scaling parameter [2111.13626].

HMMs have also been adapted to domain-specific systems:

- **Predictive maintenance**: cool-down time is treated as a noisy observation of stable and degraded operating modes; filtering yields the posterior probability of degradation after each start-up [1212.2358].
- **Human activity and visual intent**: state-dependent observation linkages represent local motion patterns in visual action sequences [1102.0899].
- **Financial regime detection**: discretized or Gaussian emissions represent latent momentum states, while IOHMMs incorporate volatility and intraday seasonality as predictors of transitions [2006.08307; 2310.03775].
- **Cybersecurity**: hidden states represent stages of an attack, observations represent user-visible or log-derived events, and Viterbi decoding reconstructs the most likely attack path [2106.02012].
- **LDPC decoding**: a four-state HMM is constructed from pairs of encoded bits, with parity constraints incorporated into emission probabilities; iterative forward-backward smoothing produces soft bit information [2509.21872].
- **Disease progression**: latent health states generate noisy diagnostic categories, while recurrent neural modules incorporate patient covariates and auxiliary clinical predictions [2006.03151].

These applications demonstrate that the HMM formalism can serve as a latent-state model, a filtering algorithm, a structured neural computation, a graph-based message-passing device, or a domain-specific representation of temporal constraints. The validity of each interpretation depends on whether the chosen state space, transition structure, emission model, and observation process adequately represent the application.

## 7. Limitations, model selection, and continuing developments

The principal limitation of a conventional HMM is the restrictive conditional-independence structure. It cannot directly represent dependence such as $P(O_{t+1}\mid O_t,Q_t)$, higher-order state dependence, arbitrary duration distributions, or observation processes with serial dependence. Extensions such as observation-linkage HMMs, Markov Observation Models, second-order HMMs, autoregressive emissions, activity-driven transitions, and recurrent sticky HDP-HMMs address different forms of this limitation.

A second limitation is parameter growth and estimation. Adding observation-linkage matrices introduces $NM^2$ parameters; second-order transitions introduce $O(N^3)$ transition parameters; belief-function models can require representations over $2^N$ subsets; and nonparametric models require MCMC or truncation choices. Sparse data can produce zero or poorly estimated probabilities, while flexible emissions and large state spaces increase overfitting risk.

A third limitation is optimization. Baum–Welch guarantees likelihood non-decrease under its standard conditions but not global optimality. Neural, Bayesian, and structured extensions inherit local optima, label symmetries, sensitivity to initialization, and possible posterior multimodality. Bayesian nonparametric methods replace fixed state-number selection with hyperparameter and inference choices, such as weak-limit truncation or beam sampling. Model selection may use likelihood, penalized likelihood, cross-validation, marginal likelihood, AIC, predictive negative log-likelihood, or application-specific metrics.

A fourth limitation concerns interpretation. Hidden states are latent explanatory constructs, not necessarily physically observable entities. Observation-linkage terms do not imply physical causality between observations, and latent-state labels are arbitrary up to permutation. Algebraic invariants describe distributional constraints but do not alone establish valid stochastic membership. In application-specific systems, manually constructed transition and emission probabilities may encode expert knowledge rather than empirical frequencies.

Despite these limitations, HMMs remain important because their latent-state semantics, dynamic-programming inference, filtering and smoothing recursions, and EM learning procedures are mathematically explicit. Contemporary work combines these properties with algebraic geometry, graphical restrictions, neural generative emissions, large-state parameter sharing, Bayesian nonparametrics, recurrent covariate dependence, distributed inference, and categorical probability. The resulting research direction is not a single replacement for the classical HMM, but a family of extensions that preserve its central separation between latent dynamics and observations while relaxing the assumptions most restrictive for particular sequential-data problems.

Source: https://www.emergentmind.com/topics/hidden-markov-model