Chapter 5

Exact inference by variable elimination

Exact inference combines the model with observed evidence to compute a query distribution. Variable elimination (VE) uses distributivity to avoid forming the full joint table. Elimination order changes intermediate work, but not the exact answer.

5.1 Factor operations

A factor is a table indexed by a set of variables called its scope. It may be a CPT, a restricted CPT or a product/sum of other factors. Intermediate factors need not be normalised distributions.

OperationScope beforeScope afterMain error to avoid
Restrict E=eE=eE,A,BE,A,BA,BA,BSumming over evidence instead
MultiplyA,BA,B and B,CB,CA,B,CA,B,CMatching rows only by row position
Sum out BBA,B,CA,B,CA,CA,CSumming before all factors containing BB are joined
Normalise queryQQQQDividing by a separate constant for each query value

5.2 Query, evidence and hidden variables

Partition the variables into query QQ, observed evidence E=eE=e and hidden variables HH. A query may itself be a vector. Keep all query variables until the final factor has been formed.

A likelihood such as P(e∣q)P(e\mid q) is not a posterior. To obtain a posterior, include the prior and all other factors, then normalise across query values. Enumeration is exact but can require exponentially many full assignments.

5.3 Variable-elimination procedure

Past papers · DA 2024–2026 (3 papers): 1 question, 1 mark

First restrict every factor containing evidence. Then choose an order of hidden variables. At each step collect all factors involving the selected variable, multiply them, sum out that variable, and replace the collected factors by the result. Multiply what remains and normalise over the query.

Unobserved leaf variables that are neither queried nor ancestors of query/evidence can be removed: their CPT sums to one. More generally prune nodes outside the ancestor set of query and evidence before numerical elimination. Preserve evidence likelihood factors even when they become scalar; they may cancel in a normalised posterior but matter for computing evidence probability or detecting impossible evidence.

5.4 Elimination order and width

Construct the interaction graph by connecting variables that share a factor scope, after evidence restriction. Eliminating a variable connects all its surviving neighbours to one another and then deletes the variable. The new edges are fill edges. Min-degree and min-fill are useful ordering heuristics, not guarantees of minimum width.

A BN with few parents per node can still have expensive inference because elimination creates larger scopes. Treewidth is the minimum induced width over complete elimination orders; the chosen order may be worse. For a conditional query, use the graph after restriction and account for query variables retained until the end.

Last-minute recall

  • Evidence is restricted, hidden variables are summed, and query variables are retained.
  • A factor's scope is its list of live variables.
  • Multiply every factor containing a variable before summing it out.
  • Intermediate factors need not sum to one.
  • Normalise once all hidden variables have been eliminated.
  • The final normalising constant equals the evidence probability when all constants are retained.
  • Elimination order changes factor sizes, not the exact posterior.
  • Prune irrelevant unobserved leaves before computing tables.
  • Small CPTs do not guarantee small intermediate factors.

Revise offline: the whole Artificial Intelligence handbook as one PDF

37 pages · 1.8 MBFree to read online. Sign in to download the PDF.We save the handbook, version and request time in My downloads. Privacy policy

All chapters · Corrections