How does the Baum–Welch algorithm (EM for an HMM) derive its updates for the transition probabilities aij and emission probabilities bj(k)?

Probabilistic models, Hidden Markov models
Level L3 Intermediate. Length Long. Nature Mat Mathematical.

What's being asked

Whether you can write the expected complete-data log-likelihood, define γ and ξ, and maximise under the sum-to-one constraints.

Key idea

E-step: compute γt(i)=P(zt=i∣O) and ξt(i,j)=P(zt=i,zt+1=j∣O). M-step: a^ij=∑tξt(i,j)/∑tγt(i) and b^j(k)=∑t:ot=kγt(j)/∑tγt(j).

Steps

  1. The complete-data log-likelihood is ln⁡πz1+∑t=1T−1ln⁡aztzt+1+∑t=1Tln⁡bzt(ot).
  2. Taking the expectation over z given O and the old parameters gives Q=∑iγ1(i)ln⁡πi+∑t=1T−1∑i,jξt(i,j)ln⁡aij+∑t=1T∑jγt(j)ln⁡bj(ot).
  3. The E-step quantities come from the forward and backward variables: ξt(i,j)=αt(i) aij bj(ot+1) βt+1(j)/P(O) and γt(i)=αt(i)βt(i)/P(O).
  4. For row i of A, maximise ∑t,jξt(i,j)ln⁡aij subject to ∑jaij=1. The Lagrangian derivative gives ∑tξt(i,j)/aij=λi, so aij∝∑tξt(i,j).
  5. Normalise: a^ij=∑t=1T−1ξt(i,j)/∑j′∑t=1T−1ξt(i,j′)=∑t=1T−1ξt(i,j)/∑t=1T−1γt(i). It is the expected number of i→j transitions divided by the expected number of visits to i.
  6. In the same way, b^j(k)=∑tγt(j) 1[ot=k]/∑tγt(j) and π^i=γ1(i).
  7. Iterate E and M steps. The likelihood P(O) never decreases, but the algorithm can reach a local maximum, so use several initialisations.

Common mistakes

How long your answer should be

A page. About 6–8 minutes.

Last checked on 4 December 2026.

Read this

Previous in Probabilistic models: A binary chain x1−x2−x3 has unary factors ϕ1=(1,3), ϕ2=(2,1), ϕ3=(3,1), and both pairwise factors are ψ(a,b)=2 if a=b and 1 otherwise. Use max-product to find the MAP assignment and its unnormalised value. How does this relate to the Viterbi algorithm?
Next in Probabilistic models: For the linear-Gaussian model xt=Axt−1+wt with wt∼N(0,Q), and yt=Hxt+vt with vt∼N(0,R), how do you derive the Kalman filter predict and update equations from the conditioning rule for Gaussians?