Rabiner 1989 - Problem 3 - Baum-Welch Reestimation

Summary

Baum-Welch iteratively reestimates from expected counts: , , . It is EM with auxiliary function , 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 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)

, and .

Expected counts (eqs 39a-b)

= expected number of transitions from (equivalently visits to , excluding ); = expected number of transitions from to .

Baum-Welch reestimation formulas (eqs 40a-c)

Baum et al. proved that either (1) the current model is a critical point of the likelihood (), or (2) . 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 [paper writes ]; maximising over gives ( likelihood increase). E-step = compute (the forward-backward counts); M-step = maximise it.

Constraints and Lagrange characterisation (eqs 43-44)

The stochastic constraints , , hold automatically at every iteration. Via Lagrange multipliers, is at a critical point iff , , ; 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 , rates . 100 EM iterations from a perturbed start returned , rates , log-likelihood vs 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 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).

Connections

Initialisation, scaling and multiple sequences are essential for practice: Rabiner 1989 - Implementation Issues - Scaling, Multiple Sequences and Initialisation. General EM relation to variational inference: The ELBO and KL Divergence Minimization.

See Also

Rabiner 1989 - HMM Tutorial - Overview, Rabiner 1989 - Problem 2 - State Posteriors and the Viterbi Algorithm