This Probability concept is the current idea: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.
Probability
Bayesian Networks
A Bayesian network turns a DAG into a compact joint distribution by storing local conditionals and reading independence from blocked or active trails.
Concept Structure
Bayesian Networks
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.
2 prerequisites 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 is a directed graph that carries probability.
Each node is a random variable. Each arrow says that one variable is allowed to appear in another variable's local conditional distribution. If the graph is a directed acyclic graph, or DAG, we can order the variables so every arrow points forward and write the joint distribution as a product of small local pieces.
That is the first reason Bayesian networks matter. A full joint table over six binary variables needs
independent probabilities. A Bayesian network can need far fewer if each node has only a few parents. The graph is a compression of assumptions.
The second reason is conceptual. The graph tells us which dependencies are supposed to be direct and which ones are only induced through paths. A fork such as
says Sprinkler and Rain can be associated because both depend on Cloudy. Once Cloudy is known, that path is blocked.
A collider such as
behaves the other way around. If Wet Grass is unobserved, that path is closed. If Wet Grass is observed, Sprinkler and Rain can become coupled by explaining the same evidence. This is the small idea behind "explaining away."
The graph does not choose the actual numbers. You still need conditional probability tables, conditional densities, or learned conditional models. But the graph chooses the local questions:
- How likely is Sprinkler given Cloudy?
- How likely is Wet Grass given Sprinkler and Rain?
- How likely is Late given Wet Grass and Traffic?
Those questions are small enough to inspect, learn, update, and later pass to inference algorithms.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Let
be random variables. A Bayesian network consists of:
- a DAG whose nodes are ;
- one local conditional distribution for each node:
where is the parent set of in the DAG.
The joint distribution factorizes as
For the lab graph, define six binary variables:
The arrows are
The factorization is therefore
For binary variables, a node with binary parents needs one independent probability for each parent assignment:
So the number of independent conditional-table parameters is
This is much smaller than the parameters in an unconstrained six-variable binary joint table.
The graph also gives conditional-independence claims. A useful local version is:
For example, Traffic has parent Rain. Once Rain is known, Traffic is separated from upstream variables such as Cloudy and Sprinkler, and from Wet Grass unless we condition on their common child Late.
Global independence claims are read through paths. A path is active or blocked depending on which variables are observed:
- A chain is blocked when is observed.
- A fork is blocked when is observed.
- A collider is closed by default, but opens when or one of its descendants is observed.
That last rule is the one many learners miss. Evidence can create dependence. If Cloudy is already known, Sprinkler and Rain are independent through their common cause. But observing Wet Grass opens the collider
so evidence for Sprinkler can reduce the need to explain Wet Grass by Rain, and vice versa.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
from itertools import product
nodes = ["C", "S", "R", "W", "T", "L"]
parents = {
"C": (),
"S": ("C",),
"R": ("C",),
"W": ("S", "R"),
"T": ("R",),
"L": ("W", "T"),
}
def binary_bn_parameter_count(parent_map):
return sum(2 ** len(parent_map[node]) for node in nodes)
def joint_probability(assignment, cpts):
prob = 1.0
for node in nodes:
parent_values = tuple(assignment[parent] for parent in parents[node])
prob *= cpts[node][parent_values][assignment[node]]
return prob
print("full joint parameters:", 2 ** len(nodes) - 1)
print("BN parameters:", binary_bn_parameter_count(parents))
print("factorization:")
for node in nodes:
ps = parents[node]
print(f"P({node}" + (f" | {','.join(ps)})" if ps else ")"))
The code is intentionally small: it does not run inference. It pins the object that inference algorithms later manipulate. A query algorithm such as variable elimination takes the local factors in this product, multiplies and sums them in a careful order, and avoids constructing the full joint table when the graph is sparse enough.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
The lab below asks you to predict what the graph encodes before it reveals the factor ledger or active trail. The same six-node DAG will be reused later for d-separation and variable elimination.
Live Concept Demo
Explore Bayesian Networks
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 Bayesian Networks 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
A Bayesian network turns a DAG into a compact joint distribution by storing local conditionals and reading independence from blocked or active trails.
Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Bayesian Networks should make visible.
Visual Inquiry
Make the image answer a mathematical question
A Bayesian network turns a DAG into a compact joint distribution by storing local conditionals and reading independence from blocked or active trails.
Which visible object should carry the first intuition?
Pick the cue that should make Bayesian Networks easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
Grounds Bayesian networks as DAGs whose joint distributions factor into local conditionals over parent sets, plus local conditional-independence semantics.
Open sourceSupports exact inference as factor manipulation and motivates keeping the factorization visible before later inference algorithms.
Open sourceProbabilistic-ML reference for directed graphical models, Bayesian-network structure, conditional independence, and inference context.
Open sourceCanonical PGM reference for the semantics of Bayesian networks, local Markov assumptions, and d-separation.
Open sourceClaim Review
A Bayesian network turns a DAG into a compact joint distribution by storing local conditionals and reading independence from blocked or active trails.
Claims without a substantive review badge still need exact source-support review.
cs228-directed-graphical-models, cs228-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-DAG factorization, parent-set CPT parameter accounting for binary variables, local Markov reading, and the fork/chain/collider active-trail cases used by the lab.
Sources: Stanford CS228 Notes: Bayesian Networks, Stanford CS228 Notes: Variable Elimination, Probabilistic Machine Learning: An Introduction, Probabilistic Graphical Models: Principles and TechniquesFinite binary teaching graph only; excludes continuous conditional densities, structure learning, parameter learning beyond CPT counting, approximate inference details, decision networks, dynamic Bayesian networks, and a GPT Pro publication pass.A bounded review summary is present; still check caveats and exact reference scope.Checked Stanford CS228 directed-model notes for the DAG factorization and local independence semantics, CS228 variable-elimination notes for exact inference as factor manipulation, Murphy's ProbML for directed graphical-model context, and Koller/Friedman as the canonical PGM reference for local Markov/d-separation semantics. GPT Pro publication critique remains pending.
Reviewer: codex-local-source-review; reviewed 2026-07-02Source support candidates
course-notes 2026Stanford CS228 Notes: Bayesian NetworksGrounds Bayesian networks as DAGs whose joint distributions factor into local conditionals over parent sets, plus local conditional-independence semantics.
course-notes 2026Stanford CS228 Notes: Variable EliminationSupports exact inference as factor manipulation and motivates keeping the factorization visible before later inference algorithms.
book 2022Probabilistic Machine Learning: An IntroductionProbabilistic-ML reference for directed graphical models, Bayesian-network structure, conditional independence, and inference context.
book 2009Probabilistic Graphical Models: Principles and TechniquesCanonical PGM reference for the semantics of Bayesian networks, local Markov assumptions, and d-separation.
Practice Loop
Try the idea before it explains itself
A Bayesian network turns a DAG into a compact joint distribution by storing local conditionals and reading independence from blocked or active trails.
Before touching the demo, predict one visible change that should happen in Bayesian Networks.
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.
Bayesian Networks
What is the smallest example that makes Bayesian Networks 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 - Bayesian Networks Selected item key: recorded for copy. Context: Probability Page anchor: recorded for copy. Open question: What is the smallest example that makes Bayesian Networks 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/bayesian-networks
concept:probability/bayesian-networks