The Message-Passing Rules
From Factor Graph to Algorithm
In Chapter 17 we saw that marginalization on a tree factor graph distributes sums inside products. The sum-product algorithm makes this distribution mechanical: every variable and factor node repeatedly applies the same local rule, and after two passes through a tree the exact marginals emerge at every node.
The point is that this algorithm is universal: the update rules depend only on the factor graph and the factor values, not on the problem domain. The same code runs on LDPC decoding, HMM filtering, and compressed sensing β only the factors change. This section establishes the rules once and for all.
Definition: Sum-Product Messages
Sum-Product Messages
Let be a distribution on a factor graph. For each directed edge, define:
- Variable-to-factor message:
- Factor-to-variable message: At convergence (or after the tree passes), the belief (approximate marginal) at variable is
The variable-to-factor message combines information from all other factors touching . The factor-to-variable message marginalizes out everything except from while weighting each neighbor by its incoming message. Messages are defined up to a scalar β normalization is imposed for numerical reasons only.
Theorem: Sum-Product Computes Exact Marginals on Trees
If the factor graph is a tree, the sum-product algorithm initialized at the leaves and run inward-then-outward terminates in operations (where is the number of directed edges) and produces beliefs (the true marginals) at every node.
The tree structure ensures that the messages arriving at node from different subtrees are statistically independent given . Their product equals the joint posterior, correctly marginalizing all other variables. This is the tree intuition: remove , the tree decomposes into disjoint subtrees, and the messages bring the subtree contributions together.
Root the tree at a chosen variable node
Choose any variable node as the root. The tree decomposes into subtrees for each neighbor factor .
Inward pass computes subtree marginals
For each subtree , recursive application of the sum-product rule computes , the 'unnormalized contribution' of subtree to .
Multiply at the root
Since the subtrees share only , the global sum factorizes: . The belief equals after normalization.
Outward pass extends to all nodes
Symmetrically, rooting at any other node yields its marginal. A single outward pass from provides all messages needed for all nodes' beliefs simultaneously. Total cost: message updates.
Sum-Product Algorithm (Generic)
Complexity: Per iteration: time. Memory: for the message table.Flooding schedule shown. Serial scheduling updates one edge at a time using the most recent messages, typically halving iteration count.
Example: Sum-Product on a Three-Variable Chain
Three binary variables with joint where and (entries indexed as ). Compute by sum-product.
Forward message from $x_1$ to $x_2$ via $f_1$
. Since is a leaf, . Thus , .
Backward message from $x_3$ to $x_2$ via $f_2$
Similarly and . , .
Belief at $x_2$
. Normalized: .
Verification
The factor product is symmetric under flips when both flipped. The marginal is uniform. β
Sum-Product Message Propagation on a Tree
Animate message passing on a tree factor graph. Observe messages flowing inward from leaves and outward to all nodes.
Parameters
Loopy BP: Same Rules, Different Guarantees
On a loopy graph, we apply the same message updates iteratively until convergence (or for a fixed number of iterations). Fixed points correspond to stationary points of the Bethe free energy (Chapter 17). For many practical graphs β LDPC codes, turbo codes, MIMO with sparse channels β loopy BP converges to beliefs close to the true marginals. The quality of the approximation depends on graph girth, factor strength, and scheduling.
Theorem: Factor-to-Variable Message for Hard Constraints
Let be a hard constraint (indicator of a feasible set). Then In particular, if the constraint is a parity check , the message admits a closed form in terms of the incoming LLRs (see Section 18.2).
When the factor is a hard constraint, only configurations satisfying it contribute to the marginal. The sum-product rule prunes all infeasible configurations.
Specialize the sum-product rule
In the general formula , insert the indicator β summands with vanish.
Parity-check closed form
For parity check, the feasibility constraint is linear mod 2. The sum over satisfying configurations factorizes: each incoming bit distribution is a Bernoulli, and the resulting message corresponds to the XOR of Bernoullis β which is a classical calculation in LLR form.
Common Mistake: Do Not Include Yourself
Mistake:
Computing β i.e., including the target factor in the product.
Correction:
The variable-to-factor message must exclude the target factor: . Including creates a self-loop of information and typically makes BP diverge even on trees. This mistake is the most common bug in homework implementations.
Extrinsic message
A message carrying information excluding the recipient's own prior contribution. Variable-to-factor messages in sum-product are extrinsic with respect to the target factor. This extrinsic structure is what enables iterative refinement: each factor receives "fresh" information at each iteration.
Related: Turbo principle, Iterative decoding
Numerical Stability: Log-Domain BP
Messages are products of many small numbers and quickly underflow to zero in naive implementations. Always work in log-domain: replace products by sums, and use the log-sum-exp trick for marginalization: . For binary variables, LLRs are the natural representation.
- β’
Never multiply raw probabilities β underflow within 20 iterations.
- β’
Use LLRs for binary; log-densities for continuous.
- β’
Clip extreme LLRs to a finite range (e.g., ) in hardware to prevent overflow.
Sum-Product on a Tree: Two-Pass Algorithm
Key Takeaway
Sum-product is a local algorithm: every message depends only on its immediate neighbors. On a tree, two passes compute exact marginals exactly; on a loopy graph, iteration yields a principled approximation. The algorithm is universal β the same code solves LDPC decoding, HMM filtering, and compressed sensing.