Skip to content
Part IA Lent Term

Hidden Markov Models: Parameter Estimation and Smoothing

Maximum Likelihood Estimation (MLE, no smoothing)

From fully labelled training data (dual-tape), count and divide:

Transitions:

aij=count(sisj)count(si)a_{ij} = \frac{\text{count}(s_i \to s_j)}{\text{count}(s_i)}

Emissions:

bi(vk)=count(si emits vk)count(si)b_i(v_k) = \frac{\text{count}(s_i \text{ emits } v_k)}{\text{count}(s_i)}

Problem: any count of zero gives probability zero. In Viterbi decoding, a zero anywhere kills that path entirely. With small training sets, many transitions and emissions will be unseen.

Laplace (Add-One) Smoothing

Transitions:

aij=count(sisj)+1count(si)+Sa_{ij} = \frac{\text{count}(s_i \to s_j) + 1}{\text{count}(s_i) + |S|}

Emissions:

bi(vk)=count(si emits vk)+1count(si)+Vb_i(v_k) = \frac{\text{count}(s_i \text{ emits } v_k) + 1}{\text{count}(s_i) + |V|}

CRITICAL: Denominators Are Different

This is the most common exam error. Transitions add S|S| (number of hidden states) to the denominator. Emissions add V|V| (number of observation symbols) to the denominator. They are different quantities and students who mix them up lose marks.

Why they differ: a transition goes to one of S|S| possible next states, so we smooth across S|S| outcomes. An emission goes to one of V|V| possible observation symbols, so we smooth across V|V| outcomes.

Full Worked Example: COVID HMM (2022 Q9)

Training Data (timesteps 1–7)

States: L, M, H, H, H, M, M Observations: +, ++, ++, +++, ++, ++, +

Counting Transitions

From / ToLMH
L010
M021
H012

count(L)=1\text{count}(L) = 1, count(M)=3\text{count}(M) = 3, count(H)=3\text{count}(H) = 3

Without smoothing:

aLM=11=1.0aMH=13aMM=23a_{L \to M} = \frac{1}{1} = 1.0 \quad a_{M \to H} = \frac{1}{3} \quad a_{M \to M} = \frac{2}{3} aHH=23aHM=13aLL=01=0a_{H \to H} = \frac{2}{3} \quad a_{H \to M} = \frac{1}{3} \quad a_{L \to L} = \frac{0}{1} = 0

aLL=0a_{L \to L} = 0 is problematic: if we ever reach state L, we cannot stay there.

With smoothing (S=3|S| = 3):

aLM=1+11+3=24aMH=1+13+3=26a_{L \to M} = \frac{1+1}{1+3} = \frac{2}{4} \quad a_{M \to H} = \frac{1+1}{3+3} = \frac{2}{6} aMM=2+13+3=36aHH=2+13+3=36a_{M \to M} = \frac{2+1}{3+3} = \frac{3}{6} \quad a_{H \to H} = \frac{2+1}{3+3} = \frac{3}{6} aHM=1+13+3=26aLL=0+11+3=14a_{H \to M} = \frac{1+1}{3+3} = \frac{2}{6} \quad a_{L \to L} = \frac{0+1}{1+3} = \frac{1}{4}

Counting Emissions

State / Obs++++++
L100
M030
H012

count(L)=1\text{count}(L) = 1, count(M)=3\text{count}(M) = 3, count(H)=3\text{count}(H) = 3

Without smoothing:

bL(+)=11=1.0bM(++)=33=1.0bH(++)=13bH(+++)=23b_L(+) = \frac{1}{1} = 1.0 \quad b_M(\text{++}) = \frac{3}{3} = 1.0 \quad b_H(\text{++}) = \frac{1}{3} \quad b_H(\text{+++}) = \frac{2}{3}

Zeros everywhere: bL(++)=0b_L(\text{++}) = 0, bL(+++)=0b_L(\text{+++}) = 0, bM(+)=0b_M(+) = 0, bM(+++)=0b_M(\text{+++}) = 0, bH(+)=0b_H(+) = 0.

With smoothing (V=3|V| = 3):

bL(+)=1+11+3=24bM(++)=3+13+3=46bH(+++)=2+13+3=36b_L(+) = \frac{1+1}{1+3} = \frac{2}{4} \quad b_M(\text{++}) = \frac{3+1}{3+3} = \frac{4}{6} \quad b_H(\text{+++}) = \frac{2+1}{3+3} = \frac{3}{6}

General Smoothing Parameter ω\omega

aij=count(sisj)+ωcount(si)+ωSa_{ij} = \frac{\text{count}(s_i \to s_j) + \omega}{\text{count}(s_i) + \omega \cdot |S|}

bi(vk)=count(si emits vk)+ωcount(si)+ωVb_i(v_k) = \frac{\text{count}(s_i \text{ emits } v_k) + \omega}{\text{count}(s_i) + \omega \cdot |V|}

Laplace smoothing is the special case ω=1\omega = 1. ω\omega can be tuned on a development set (cross-validation).

Summary

QuantityMLE (no smoothing)Laplace (add-one)
aija_{ij}count(sisj)count(si)\frac{\text{count}(s_i \to s_j)}{\text{count}(s_i)}count(sisj)+1count(si)+S\frac{\text{count}(s_i \to s_j) + 1}{\text{count}(s_i) + \|S\|}
bi(vk)b_i(v_k)count(si emits vk)count(si)\frac{\text{count}(s_i \text{ emits } v_k)}{\text{count}(s_i)}count(si emits vk)+1count(si)+V\frac{\text{count}(s_i \text{ emits } v_k) + 1}{\text{count}(s_i) + \|V\|}
Smoothing amountNoneShift mass from seen to unseen
Most common errorAdding V\|V\| to transition denominator

Past paper questions: y2022p3q9, y2024p3q8, y2025p3q9