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?

Probabilistic models, Belief propagation
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can replace sums by maxima in message passing and recover the argmax by backtracking.

Key idea

Max-product uses mi→j(xj)=max⁡xiϕi(xi)ψ(xi,xj)∏kmk→i(xi). The MAP value is the maximum of the final product, and the argmaxes are recorded to trace back.

Steps

  1. Message from x1 to x2: for x2=0, max⁡(1⋅2,  3⋅1)=3 (at x1=1). For x2=1, max⁡(1⋅1,  3⋅2)=6 (at x1=1).
  2. Message from x3 to x2: for x2=0, max⁡(3⋅2,  1⋅1)=6 (at x3=0). For x2=1, max⁡(3⋅1,  1⋅2)=3 (at x3=0).
  3. Max-marginal at x2: ϕ2⋅m1→2⋅m3→2=(2⋅3⋅6,  1⋅6⋅3)=(36,18). So the best x2 is 0 and the MAP value is 36.
  4. Backtrack: with x2=0 the stored argmaxes give x1=1 and x3=0. MAP assignment (1,0,0).
  5. Check by direct product: ϕ1(1) ϕ2(0) ϕ3(0) ψ(1,0) ψ(0,0)=3⋅2⋅3⋅1⋅2=36.
  6. Relation to Viterbi: Viterbi is max-product on the chain of an HMM, with δt(j)=max⁡iδt−1(i) aij bj(ot) and back-pointers. In practice we use logs, so max-product becomes max-sum.

Common mistakes

How long your answer should be

Half a page.

Last checked on 4 December 2026.

Read this

Previous in Probabilistic models: Three binary variables form a chain x1−x2−x3 with unary factors ϕ1=(1,2), ϕ2=(1,1), ϕ3=(3,1) (for values 0 and 1), and the same pairwise factor on both edges, ψ(a,b)=2 if a=b and 1 otherwise. Using sum-product messages, what are p(x2) and p(x3)?
Next in Probabilistic models: How does the Baum–Welch algorithm (EM for an HMM) derive its updates for the transition probabilities aij and emission probabilities bj(k)?