Quant Memo
Advanced

Belief Propagation and Message Passing

Belief propagation computes exact probabilities in a graphical model without ever building the full joint distribution, by having each node pass small summary 'messages' to its neighbors and combining incoming messages into an updated belief — the same message-passing idea graph neural networks later borrowed.

Prerequisites: Bayesian Networks and Joint Factorization, D-Separation and Reading Independence Off a Graph

Given a Bayesian network factored into small local pieces, a natural next question is: what is the probability of some variable of interest, given evidence observed elsewhere in the network? Multiplying out the full joint distribution and marginalizing directly is exactly the astronomically large computation the factorization was supposed to avoid. Belief propagation solves this without ever forming the full joint: each node sends small "messages" — compact summaries of what it currently believes — to its neighbors, each node updates its own belief from the messages it receives, and after one pass through the graph every node holds the exact marginal probability it would have gotten from grinding through the whole joint distribution.

The analogy: passing a rumor down a line, but honestly

Imagine a line of people, each only able to talk to their immediate neighbors, trying to collectively figure out the probability of some event based on clues each person individually holds. Instead of everyone shouting their raw clue to everyone else (impossible in a large crowd), each person combines their own clue with whatever summary message their neighbor just handed them, then passes an updated summary further down the line. By the time a summary has traveled from one end of the line to the other and back, everyone holds a belief that correctly reflects everyone's clues combined — without any single person ever having heard every clue directly. Belief propagation is this process formalized: a message is a compact function (not the raw data), passed link by link, that mathematically guarantees the same exact answer as if everything had been computed jointly.

The message and belief update rules

A message from node ii to a neighboring node jj summarizes everything ii knows, excluding what it just heard from jj itself (to avoid double-counting):

mij(xj)=xiϕ(xi)ψ(xi,xj)kN(i)jmki(xi)m_{i \to j}(x_j) = \sum_{x_i} \phi(x_i)\, \psi(x_i, x_j) \prod_{k \in N(i) \setminus j} m_{k \to i}(x_i)

In words: to tell jj what it believes about jj's possible values, node ii takes its own local evidence ϕ(xi)\phi(x_i), combines it with the compatibility function ψ(xi,xj)\psi(x_i,x_j) linking ii and jj, multiplies in every message ii has received from its other neighbors (everyone except jj, since jj already knows its own message), and sums out ii's own possible values — the result is a function of xjx_j alone, exactly the summary jj needs. Once every message has been passed, a node's final belief is the product of all incoming messages and its own local evidence:

b(xj)ϕ(xj)iN(j)mij(xj)b(x_j) \propto \phi(x_j) \prod_{i \in N(j)} m_{i \to j}(x_j)

In words: node jj's final belief about its own value is proportional to its own evidence times every incoming message, combining everything the rest of the graph told it into one normalized probability.

Worked example 1: a 3-node chain by hand

Take the rain-train-late chain RTLR \to T \to L from Bayesian network factorization, with the same numbers: p(R=yes)=0.2p(R{=}\text{yes})=0.2, p(T=yesR=yes)=0.7p(T{=}\text{yes}\mid R{=}\text{yes})=0.7, p(T=yesR=no)=0.1p(T{=}\text{yes}\mid R{=}\text{no})=0.1, p(L=yesT=yes)=0.8p(L{=}\text{yes}\mid T{=}\text{yes})=0.8, p(L=yesT=no)=0.05p(L{=}\text{yes}\mid T{=}\text{no})=0.05. To find p(L=yes)p(L{=}\text{yes}) with no evidence observed: the message from RR to TT is just RR's marginal folded through the conditional, mRT(T=yes)=0.2(0.7)+0.8(0.1)=0.14+0.08=0.22m_{R\to T}(T{=}\text{yes}) = 0.2(0.7) + 0.8(0.1) = 0.14+0.08=0.22. This becomes TT's belief: p(T=yes)=0.22p(T{=}\text{yes}) = 0.22 (so p(T=no)=0.78p(T{=}\text{no})=0.78). The message from TT to LL: mTL(L=yes)=0.22(0.8)+0.78(0.05)=0.176+0.039=0.215m_{T\to L}(L{=}\text{yes}) = 0.22(0.8) + 0.78(0.05) = 0.176 + 0.039 = 0.215. So p(L=yes)=0.215p(L{=}\text{yes}) = 0.215 — computed by passing two small messages down the chain, never touching a joint table over all three variables at once.

Worked example 2: updating the belief after evidence arrives

Now suppose you directly observe T=yesT{=}\text{yes} (you know for a fact the train was delayed). TT's belief is now fixed at p(T=yes)=1p(T{=}\text{yes})=1 rather than the computed 0.220.22, and it sends a fresh message forward: mTL(L=yes)=1(0.8)+0(0.05)=0.8m_{T\to L}(L{=}\text{yes}) = 1(0.8) + 0(0.05) = 0.8. LL's belief updates immediately to p(L=yesT=yes)=0.8p(L{=}\text{yes}\mid T{=}\text{yes}) = 0.8 — a large jump up from the unconditional 0.2150.215, computed simply by replacing one message with the new evidence and re-propagating, without recomputing anything about RR or re-deriving the whole joint distribution from scratch.

Function explorer
-221.1
x = 1.00f(x) = 0.731

Each belief-propagation message is a function of one node's possible values, combined and squashed the same general way the curve above combines an input into a bounded probability-like output.

Belief propagation computes exact marginal probabilities by passing compact messages along a graph's edges and combining incoming messages at each node — it gets the same answer as brute-force joint-distribution marginalization, at a fraction of the computational cost, and updates cleanly when new evidence is observed.

What this means in practice

Exact belief propagation as described here is guaranteed correct only on graphs without cycles (trees, or chain-like structures); on graphs with loops, the same message-passing rules are still applied anyway — called loopy belief propagation — and while no longer exact, it converges to good approximations in practice and underlies decoding algorithms in communications (turbo codes, LDPC codes) as well as inference in financial graphical models like credit contagion networks. The message-passing idea itself was later generalized and borrowed directly by message-passing neural networks and GNNs, which replace belief propagation's exact probabilistic messages with learned vector messages — the algorithmic skeleton is the same.

Practice

  1. Recompute p(L=yes)p(L{=}\text{yes}) if instead p(R=yes)=0.5p(R{=}\text{yes})=0.5, keeping all conditional probabilities the same.
  2. Explain in one sentence why belief propagation is only guaranteed exact on a graph with no cycles.
  3. After observing T=noT{=}\text{no} instead of T=yesT{=}\text{yes}, recompute LL's updated belief.

The common confusion is assuming loopy belief propagation (running the same message-passing rules on a graph that has cycles) gives exact answers just because it usually gives reasonable answers in practice. On a graph with cycles, a message can circulate back around and get counted more than once, so the result is an approximation with no general correctness guarantee — it can even fail to converge at all on some graphs. Whether a given graph is a tree (exact) or has cycles (approximate at best) needs to be checked before trusting belief propagation's output as exact.

Related concepts

Practice in interviews

Further reading

  • Pearl, Probabilistic Reasoning in Intelligent Systems (1988)
  • Yedidia, Freeman & Weiss, Understanding Belief Propagation and Its Generalizations (2003)
ShareTwitterLinkedIn