Why is exact inference in a Markov random field generally intractable, and what structural property of the graph enables exact inference in special cases?
Think about your answer, then reveal below.
Model answer: Exact inference requires computing marginal probabilities, which involves the partition function Z — the sum of the unnormalized joint distribution over all possible configurations of all variables. With n binary variables, this sum has 2^n terms, making it exponential in the number of variables. Exact inference is tractable only when the graph is a tree (or can be converted to one via junction tree methods), because trees have no loops, allowing messages to propagate exactly from leaves to root without double-counting. Belief propagation is exact on trees and becomes approximate (loopy belief propagation) on graphs with cycles.
The hardness of inference in MRFs is one of the central challenges of probabilistic graphical models. The exponential partition function is the culprit: even evaluating the probability of a single configuration requires knowing Z, which is a sum over all configurations. Trees are the exception because their acyclic structure allows a dynamic programming decomposition that computes marginals in polynomial time. Most real problems involve graphs with loops (images, protein contact maps, spatial grids), where approximate methods — belief propagation, variational inference, MCMC — are essential.