This Probability concept is the current idea: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.
Probability
Variable Elimination
Variable elimination answers exact Bayesian-network queries by joining only the needed factors, summing hidden variables away, and watching the largest intermediate table.
Concept Structure
Variable Elimination
Start with the picture, metaphor, or geometric mechanism.
Make the objects explicit and connect them with notation.
Mirror the equations with runnable implementation details.
Manipulate the mechanism and watch the idea respond.
Learner Contract
What this page should let you do.
1 prerequisite listed; refresh them before leaning on the math or code.
Explain the mechanism, trace the main notation, and test one prediction in the live demo.
Read the intuition before the notation; the math should name a mechanism you already felt.
Follow this edge after making one prediction here; the next page should reuse the result, not restart the route.
Claim/source review status
Substantive review recorded
1/1 claims have bounded review metadata; still check caveats and source scope.Metadata-derived; review may be AI-assisted. Not a human certification.01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
A Bayesian network gives us many small probability tables. Exact inference asks a larger question:
The blunt way is to build the whole joint table, filter the rows where Cloudy is true, add up every hidden variable, and normalize. That works for a toy network, but it teaches the wrong habit. The table grows exponentially with the number of variables.
Variable elimination keeps the local factorization alive. It starts with the conditional tables that mention the evidence, query, and hidden variables. Then it chooses one hidden variable at a time:
- join every factor that mentions that variable;
- sum the variable out of the joined factor;
- put the smaller factor back into the ledger.
The order matters. Eliminating Wet Grass first in the lab below creates a joined factor over
which has rows for binary variables. Eliminating Sprinkler first creates only an -row joined factor. Same query, same network, different cost.
That is the real lesson: variable elimination is not just an algorithm name. It is a way of pushing sums inward so we avoid the full joint table when the graph structure lets us.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Reuse the six binary variables from the Bayesian-network page:
The joint distribution factorizes as
For the query , treat as evidence and remove from the remaining factor scopes:
The query is
where is the normalizing constant that makes the two values of sum to one.
Variable elimination chooses an order for the hidden variables . If the next variable is , collect the current factors that mention :
Join them:
then sum out :
Replace with and continue.
The expensive object is the joined factor , not the final answer. For binary variables, a joined factor with variables has
rows. The largest such scope is the practical warning sign. In larger graphs, this is the intuition behind induced width, treewidth, junction trees, and why exact inference can become impossible even when the original factors are small.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
order_cases = {
"efficient": ["S", "R", "W", "T"],
"wet_first": ["W", "S", "R", "T"],
"traffic_first": ["T", "W", "R", "S"],
}
factors = [
("P(S|C=true)", {"S"}),
("P(R|C=true)", {"R"}),
("P(W|S,R)", {"W", "S", "R"}),
("P(T|R)", {"T", "R"}),
("P(L|W,T)", {"L", "W", "T"}),
]
def rows(scope):
return 2 ** len(scope)
def eliminate(order):
live = [(name, set(scope)) for name, scope in factors]
steps, largest = [], 0
for z in order:
used = [(name, scope) for name, scope in live if z in scope]
kept = [(name, scope) for name, scope in live if z not in scope]
joined = set().union(*(scope for _, scope in used))
result = joined - {z}
largest = max(largest, rows(joined))
steps.append((z, sorted(joined), rows(joined), sorted(result)))
live = kept + [(f"sum_{z}", result)]
return largest, steps
for name, order in order_cases.items():
largest, steps = eliminate(order)
print(name, "largest joined factor:", largest, "rows")
The code intentionally tracks scopes and row counts, not probability values. That is enough to reveal the central mechanism: variable elimination can return an exact answer while its cost is controlled by the largest intermediate factor it creates.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
Choose an elimination order, predict the largest joined factor, then reveal the ledger. The answer is hidden until you commit so the row-count explosion becomes something you reason through rather than something you merely read.
Live Concept Demo
Explore Variable Elimination
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Commit to what Variable Elimination should make visible before reading the result.
After The First Pass
Turn the concept into an inspected object.
Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.
Mechanism Storyboard
See the idea move before the page explains it
Variable elimination answers exact Bayesian-network queries by joining only the needed factors, summing hidden variables away, and watching the largest intermediate table.
Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Variable Elimination should make visible.
Visual Inquiry
Make the image answer a mathematical question
Variable elimination answers exact Bayesian-network queries by joining only the needed factors, summing hidden variables away, and watching the largest intermediate table.
Which visible object should carry the first intuition?
Pick the cue that should make Variable Elimination easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
Grounds variable elimination as multiplying relevant factors, summing out hidden variables, and exposing order-dependent intermediate factor growth.
Open sourceSupports the join-and-eliminate procedure and the contrast with constructing a full joint table.
Open sourceOpen-source implementation reference for exact inference APIs and elimination-order heuristics such as induced width.
Open sourceProbabilistic-ML reference for graphical-model inference and factor operations.
Open sourceCanonical PGM reference for exact inference, factor graphs, induced width, and junction-tree motivation.
Open sourceClaim Review
Variable elimination answers exact Bayesian-network queries by joining only the needed factors, summing hidden variables away, and watching the largest intermediate table.
Claims without a substantive review badge still need exact source-support review.
cs228-variable-elimination, berkeley-cs188-variable-elimination, pgmpy-variable-elimination, murphy-2022-probabilistic-ml, koller-friedman-2009-pgm
Use equations, runnable code, and demos to check whether the source support is operational.
The sources support the page's finite discrete factor procedure, evidence-first restriction, join then sum-out update, order-dependent intermediate row counts, and the induced-width intuition that motivates junction-tree and message-passing methods.
Sources: Stanford CS228 Notes: Variable Elimination, Berkeley CS188 Textbook: Variable Elimination, pgmpy Documentation: Variable Elimination, Probabilistic Machine Learning: An Introduction, Probabilistic Graphical Models: Principles and TechniquesFinite binary teaching graph only; excludes continuous variables, numerical factor values beyond scope/row-count witnesses, MAP elimination, junction-tree calibration, approximate inference, and a GPT Pro publication pass.A bounded review summary is present; still check caveats and exact reference scope.Checked Stanford CS228 for the algebra of moving sums inward through factor products and for order-dependent intermediate factors; checked Berkeley CS188 for the join/sum-out procedure and full-joint contrast; checked pgmpy docs for exact-inference APIs, elimination orders, and induced-width language; used Murphy and Koller/Friedman as book anchors for PGM inference context. GPT Pro publication critique remains pending because 127.0.0.1:51672 is unavailable.
Reviewer: codex-local-source-review; reviewed 2026-07-02Source support candidates
course-notes 2026Stanford CS228 Notes: Variable EliminationGrounds variable elimination as multiplying relevant factors, summing out hidden variables, and exposing order-dependent intermediate factor growth.
course-notes 2026Berkeley CS188 Textbook: Variable EliminationSupports the join-and-eliminate procedure and the contrast with constructing a full joint table.
documentation 2026pgmpy Documentation: Variable EliminationOpen-source implementation reference for exact inference APIs and elimination-order heuristics such as induced width.
book 2022Probabilistic Machine Learning: An IntroductionProbabilistic-ML reference for graphical-model inference and factor operations.
Practice Loop
Try the idea before it explains itself
Variable elimination answers exact Bayesian-network queries by joining only the needed factors, summing hidden variables away, and watching the largest intermediate table.
Before touching the demo, predict one visible change that should happen in Variable Elimination.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
A concrete answer is on the canvas.
The answer names why the claim should hold.
It touches the page context or a neighboring idea.
Research Room
Attach the question to a claim, equation, code, or demo
Pick the concept, equation, source, runnable code, claim, misconception, or demo state before asking for help. The handoff keeps that page item in context.Open the draft below to save one note and next action in this browser.
Variable Elimination
What is the smallest example that makes Variable Elimination click without losing the math?
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays in this browser, attached to the selected learning item.
- References to inspect: attached references on this page.
- Definition, prerequisite, and contrast concept links
- The equation or runnable code that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - Variable Elimination Selected item key: recorded for copy. Context: Probability Page anchor: recorded for copy. Open question: What is the smallest example that makes Variable Elimination click without losing the math? Evidence to inspect: - References to inspect: attached references on this page. - Definition, prerequisite, and contrast concept links - The equation or runnable code that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.
concept/concept-notebook/probability/variable-elimination
concept:probability/variable-elimination