Rabiner 1989 - Problem 3 - Baum-Welch Reestimation
Summary
Baum-Welch iteratively reestimates λ=(A,B,π) from expected counts: aˉij=∑tξt(i,j)/∑tγt(i), bˉj(k)=∑t:Ot=vkγt(j)/∑tγt(j), πˉi=γ1(i). It is EM with auxiliary function Q(λ,λˉ), monotonically increases likelihood and converges to a local maximum only. It automatically preserves the stochastic constraints and any zero entries.
Overview
“The third, and by far the most difficult, problem of HMMs is to determine a method to adjust the model parameters.” No analytic solution exists; one chooses λ so P(O∣λ) is locally maximised using Baum-Welch (equivalently EM; Dempster, Laird and Rubin 1977) or gradient techniques.
Main Content
Transition posterior ξ (eqs 36-38; Fig. 6)
ξt(i,j)=P(qt=Si,qt+1=Sj∣O,λ)=P(O∣λ)αt(i)aijbj(Ot+1)βt+1(j)=∑i∑jαt(i)aijbj(Ot+1)βt+1(j)αt(i)aijbj(Ot+1)βt+1(j), and γt(i)=∑jξt(i,j).
Expected counts (eqs 39a-b)
∑t=1T−1γt(i) = expected number of transitions from Si (equivalently visits to Si, excluding t=T); ∑t=1T−1ξt(i,j) = expected number of transitions from Si to Sj.
Baum et al. proved that either (1) the current model λ is a critical point of the likelihood (λˉ=λ), or (2) P(O∣λˉ)>P(O∣λ). Iterating converges to a critical point, a maximum-likelihood estimate; “the forward-backward algorithm leads to local maxima only” and the likelihood surface has many local maxima.
EM interpretation (eqs 41-42)
Baum’s auxiliary function Q(λ,λˉ)=∑QP(Q∣O,λ)logP(O,Q∣λˉ) [paper writes P(Q∣O,λ)log[P(O,Q∣λˉ)]]; maximising over λˉ gives P(O∣λˉ)≥P(O∣λ) (maxλˉQ⇒ likelihood increase). E-step = compute Q (the forward-backward counts); M-step = maximise it.
Constraints and Lagrange characterisation (eqs 43-44)
The stochastic constraints ∑iπˉi=1, ∑jaˉij=1, ∑kbˉj(k)=1 hold automatically at every iteration. Via Lagrange multipliers, P is at a critical point iff πi=∑kπk∂P/∂πkπi∂P/∂πi, aij=∑kaik∂P/∂aikaij∂P/∂aij, bj(k)=∑ℓbj(ℓ)∂P/∂bj(ℓ)bj(k)∂P/∂bj(k); manipulation shows the right-hand sides equal (40a-c), so the reestimates are exactly critical points. Gradient techniques give comparable solutions (ref [14]).
Baum-Welch on simulated data (numpy)
Data: 200 steps from the 2-state Poisson HMM with A=(.9.2.1.8), rates (1,6). 100 EM iterations from a perturbed start returned A^≈(.95.19.05.81), rates (0.98,5.12), log-likelihood −330.18 vs −335.36 at the true parameters (EM maximises the in-sample likelihood, so it exceeds the truth’s value: a reminder that MLE overfits small samples).
def baum_welch(y, N=2, iters=100): # Poisson emissions; uses forward/backward from the previous note A = np.full((N,N), 1/N) + 0.1*rng.random((N,N)); A /= A.sum(1, keepdims=True) pi = np.ones(N)/N; lam = np.array([y.mean()*0.5, y.mean()*1.5]) for _ in range(iters): logB = poisson.logpmf(y[:, None], lam[None, :]) la = forward(logB, np.log(A), np.log(pi)); lb = backward(logB, np.log(A)); ll = logsumexp(la[-1]) g = np.exp(la + lb - ll) xi = np.exp(la[:-1, :, None] + np.log(A)[None] + (logB[1:] + lb[1:])[:, None, :] - ll) pi = g[0]; A = xi.sum(0)/g[:-1].sum(0)[:, None]; lam = (g*y[:, None]).sum(0)/g.sum(0) return A, pi, lam, ll
EM vs Bayesian. Baum-Welch returns a point estimate (local MLE) with no uncertainty, is sensitive to initialisation, can drive states to degenerate solutions, and is invariant to relabelling. A Bayesian treatment instead puts Dirichlet priors on rows of A and priors on emission parameters, marginalises the hidden path with the forward algorithm, and samples (NUTS); the price is label switching, handled by ordering constraints (Bayesian HMMs - Label Switching, Non-Homogeneous Transitions and Dwell Times).