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)?

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

What's being asked

Whether you can compute sum-product messages and combine them into marginals on a tree.

Key idea

Message: mi→j(xj)=∑xiϕi(xi) ψ(xi,xj)∏k≠jmk→i(xi). Marginal: p(xj)∝ϕj(xj)∏kmk→j(xj).

Steps

  1. Message from the leaf x1 to x2: m1→2(x2)=∑x1ϕ1(x1)ψ(x1,x2). For x2=0: 1⋅2+2⋅1=4. For x2=1: 1⋅1+2⋅2=5.
  2. Message from the leaf x3 to x2: for x2=0: 3⋅2+1⋅1=7. For x2=1: 3⋅1+1⋅2=5.
  3. Belief at x2: ϕ2⋅m1→2⋅m3→2=(4⋅7,  5⋅5)=(28,25). Normalise by 53: p(x2=0)=28/53=0.528.
  4. Message from x2 to x3 uses only the message from x1 (not the one from x3): m2→3(x3)=∑x2ϕ2(x2) m1→2(x2) ψ(x2,x3). For x3=0: 4⋅2+5⋅1=13. For x3=1: 4⋅1+5⋅2=14.
  5. Belief at x3: ϕ3⋅m2→3=(3⋅13,  1⋅14)=(39,14), so p(x3=0)=39/53=0.736.
  6. Check by brute force: summing all 8 unnormalised states gives Z=53, and the weights with x3=0 add to 39. They agree, as expected on a tree.

Common mistakes

How long your answer should be

Half a page.

Last checked on 4 December 2026.

Read this

Previous in Probabilistic models: A Bayesian network has a root X0 and n children X1,…,Xn, with arrows X0→Xi, all variables binary. To compute P(X1) with no evidence, compare the cost of eliminating X0 first against eliminating Xn,…,X2 first. What is the induced width in each case?
Next 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?