Why does the plain HMM forward algorithm underflow for long sequences, and how does the scaled forward algorithm fix it? How can you illustrate this using the HMM with , , , , , and observations ?
Probabilistic models, Hidden Markov models
Level L4 Advanced. Length Medium. Nature Th+Mat Both.
What's being asked
Whether you can derive the scaling constants and show that .
Key idea
Normalise at each step: and . Then , so is safe to compute.
Steps
- is the probability of the whole prefix, so it is a product of terms of size less than 1. If each step contributes about , then after about 300 steps it falls below the smallest double-precision number () and becomes 0.
- Scaled recursion: compute the unnormalised . Set and . Now is the filtering distribution and sums to 1.
- Why the product works: by induction, and , so . Also .
- Example, : , so and .
- (observation ): and . So .
- , which matches the unscaled answer, and .
- The backward pass is scaled with the same , so and stay stable in Baum–Welch.
Common mistakes
- Computing by taking the log of each unscaled entry and adding. The recursion needs sums of probabilities, so you must either scale (as here) or use log-sum-exp.
- Forgetting the terms, which are needed for the likelihood.
- Scaling the forward pass but not the backward pass, which makes inconsistent.
How long your answer should be
Half a page, with the two scaling constants.
Last checked on 4 December 2026.
Read this
Previous in Probabilistic models: Use the Laplace approximation to the posterior to approximate the log evidence for i.i.d. data points and parameters. How does this lead to the BIC, and when does it break down?
Next in Probabilistic models: Show that a single-site Gibbs update is a Metropolis–Hastings move that is always accepted, and that it leaves the target invariant. Why does a fixed-order sweep not give a reversible chain, and can you give an example where Gibbs sampling fails to converge?