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 π=(0.5,0.5), A=(0.70.30.40.6), P(a∣1)=0.9, P(a∣2)=0.2, P(b∣1)=0.1, P(b∣2)=0.8 and observations (a,b)?

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 ct and show that ln⁡P(O)=∑tln⁡ct.

Key idea

Normalise αt at each step: ct=∑jα~t(j) and α^t=α~t/ct. Then P(O)=∏tct, so ln⁡P(O)=∑tln⁡ct is safe to compute.

Steps

  1. αt(i) is the probability of the whole prefix, so it is a product of t terms of size less than 1. If each step contributes about 0.1, then after about 300 steps it falls below the smallest double-precision number (≈10−308) and becomes 0.
  2. Scaled recursion: compute the unnormalised α~t(j)=bj(ot)∑iα^t−1(i) aij. Set ct=∑jα~t(j) and α^t=α~t/ct. Now α^t is the filtering distribution P(zt∣o1:t) and sums to 1.
  3. Why the product works: αt=α^t∏s≤tcs by induction, and ∑iαT(i)=P(O), so P(O)=∏tct. Also ct=P(ot∣o1:t−1).
  4. Example, t=1: α~1=(0.45,0.10), so c1=0.55 and α^1=(0.818,0.182).
  5. t=2 (observation b): α~2(1)=0.1 (0.818⋅0.7+0.182⋅0.4)=0.0645 and α~2(2)=0.8 (0.818⋅0.3+0.182⋅0.6)=0.2836. So c2=0.3482.
  6. P(O)=0.55⋅0.3482=0.1915, which matches the unscaled answer, and ln⁡P(O)=ln⁡0.55+ln⁡0.3482=−0.598−1.055=−1.653.
  7. The backward pass is scaled with the same ct, so γ and ξ stay stable in Baum–Welch.

Common mistakes

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 ln⁡p(D) for N i.i.d. data points and M 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 p(x) invariant. Why does a fixed-order sweep not give a reversible chain, and can you give an example where Gibbs sampling fails to converge?