Rabiner 1989 - Implementation Issues - Scaling, Multiple Sequences and Initialisation

Summary

Forward variables underflow exponentially with , so scale by ; the scale factors cancel exactly in the reestimation formulas and . Multiple observation sequences are handled by summing expected counts, each weighted by . Good initial emission estimates matter, small-sample estimates need interpolation or floors, and model size is chosen by experience.

Overview

Section V is explicitly practical (“seat-of-the-pants experience gained from working with HMMs over the last several years”) but contains exact derivations for scaling.

Main Content

Scaling (eqs 91-103)

is a sum of terms each below 1, so for the dynamic range exceeds any machine precision. Define, with and scale (eq. 91): . Then and . Scaled backward variables use the same factors: ( with ). In the reestimation of the factor is independent of and cancels between numerator and denominator, giving the exact unscaled formula in terms of scaled variables (eq. 98). Since :

Scaling can be applied only when needed (set at other times). Viterbi needs no scaling if done in logs ( recursion, eqs 104-105).

Multiple observation sequences (eqs 106-111)

For left-right models a single sequence cannot train all parameters. With independent sequences , maximise . Add the per-sequence expected counts:

is not reestimated for left-right (). With scaling, the same scale factors cancel in (eq. 111). This is the batched analogue of E24’s “padded multi-track HMM” (elk tracks as independent sequences with shared parameters).

Initial estimates (Sec. V.C)

No simple answer for reaching the global maximum. Random (subject to constraints) or uniform initialisation of and suffices in almost all cases. For , good initial estimates are helpful in the discrete-symbol case and essential in the continuous (mixture) case, obtained by manual segmentation, maximum-likelihood segmentation with averaging, or segmental -means with clustering.

Insufficient training data (Sec. V.D; eqs 112-113; Fig. 10)

(1) Enlarge the training set (often impractical); (2) reduce model size (often impossible); (3) interpolate with a smaller model for which data suffice: (eq. 112), with estimated by deleted interpolation (Jelinek and Mercer 1980) by treating the interpolation as an expanded HMM with a neutral state (Fig. 10) and running forward-backward on held-out partitions; (4) floors: require (eq. 113a) or (113b), with a post-processing step that corrects violations and rescales.

Choice of model (Sec. V.E). No theoretically correct rule: model type (ergodic or left-right), number of states, observation type (discrete or continuous, number of mixtures) are chosen by the physics of the signal and by experiment. A modern Bayesian answer is cross-validation or integrated LOO over the hidden path (E24).

Why scaling matters (numpy)

import numpy as np
rng = np.random.default_rng(0)
N, T = 3, 2000
A = np.full((N,N), 1/N); b = rng.random((T,N))*0.2             # tiny emission likelihoods
alpha = np.ones(N)/N*b[0]; logp = 0.0
for t in range(1, T):
    alpha = (alpha @ A)*b[t]
    c = alpha.sum(); alpha /= c; logp += np.log(c)             # scale c_t^{-1}; logp = -sum log c_t (eq. 103)
print(logp)   # finite; unscaled alpha would be ~ 0.1^2000 -> underflow to 0.0 in float64

Connections

Log-space forward algorithms (logsumexp) in PyMC/JAX are the modern replacement for explicit scaling: Rabiner 1989 - Problem 1 - Forward and Backward Algorithms. Gradient-based Bayesian fitting avoids Baum-Welch initialisation issues but inherits multimodality as label switching.

See Also

Rabiner 1989 - HMM Tutorial - Overview, Rabiner 1989 - Problem 3 - Baum-Welch Reestimation