Probability

d-Separation

d-Separation is the graph test that says which conditional independencies a Bayesian-network DAG guarantees after evidence is observed.

status: reviewimportance: importantdifficulty 4/5math: graduateread: 24mlive demo

Concept Structure

d-Separation

01Intuition

Start with the picture, metaphor, or geometric mechanism.

02Math

Make the objects explicit and connect them with notation.

03Code

Mirror the equations with runnable implementation details.

04Interactive Demo

Manipulate the mechanism and watch the idea respond.

1prerequisites
3next concepts
3related links

Learner Contract

What this page should let you do.

You are here becaused-Separation is the graph test that says which conditional independencies a Bayesian-network DAG guarantees after evidence is observed.

This Probability concept is the current idea: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.

Before thisBayesian Networks (review)

1 prerequisite listed; refresh them before leaning on the math or code.

By the end4/4 sections ready | runnable code expected | live demo

Explain the mechanism, trace the main notation, and test one prediction in the live demo.

Do this firstIntuition

Read the intuition before the notation; the math should name a mechanism you already felt.

Then go nextVariable Elimination (review)

Follow this edge after making one prediction here; the next page should reuse the result, not restart the route.

Test the linkManipulate one control and predict the visible change.Then continue to Variable Elimination (review)

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.
Claims1/1 reviewed
Sources5 cited
Codeattached
Demolive
Reviewed2026-07-02
Updatedpage 2026-07-02

Learning item flow

4/4 sections readyAsk about thisResearch room
Conceptd-SeparationProbability
5 sources attachedLocal snapshot ready
concept:probability/d-separation
01

01

Intuition

Build the mental picture first so the rest of the page has something to attach to.

Section prompt

A Bayesian network is useful only if we can read more than parent lists from it. We also need to know which variables become irrelevant once evidence is observed.

That is the job of d-separation.

Start with a question such as:

SRC?S \perp R \mid C?

Read it as: "Once Cloudy is known, does the graph guarantee that Sprinkler and Rain carry no extra information about each other?"

The answer is a graph question before it is a probability-table question. Forget arrow direction for a moment and look for every undirected trail between the query nodes. Evidence can block or open each trail.

Three local patterns do almost all the work:

  • Chain: ABCA \to B \to C. Observing the middle node BB blocks the trail.
  • Fork: ABCA \leftarrow B \to C. Observing the common cause BB blocks the trail.
  • Collider: ABCA \to B \leftarrow C. The trail is closed by default, but observing BB opens it.

The collider rule is the strange one. It says evidence can create dependence. If Wet Grass is observed, Sprinkler and Rain become competing explanations for the same effect.

There is one more subtlety: observing a descendant of a collider also opens the collider. If Sprinkler and Rain both point to Wet Grass, and Wet Grass points to Late, then observing Late can make the Sprinkler--Wet Grass--Rain trail active even when Wet Grass itself is not observed.

So d-separation is not "draw arrows and follow causality." It is a trail audit:

  1. list the undirected trails between the query nodes;
  2. classify each middle node as a non-collider or collider;
  3. apply the evidence rule;
  4. check whether any whole trail stays active.

If no active trail remains, the DAG guarantees conditional independence for every distribution that factorizes over that graph. If at least one active trail remains, the graph does not guarantee independence. Special probability values might still cancel, but the graph alone no longer proves it.

02

02

Math

Translate the story into symbols, assumptions, and a derivation you can inspect.

Section prompt

Let G=(V,E)G=(V,E) be a directed acyclic graph for a Bayesian network. Let X,Y,ZVX,Y,Z \subseteq V be disjoint sets of nodes. The set ZZ is the evidence or conditioning set.

An undirected trail

π=(v0,v1,,vm)\pi = (v_0,v_1,\ldots,v_m)

connects v0Xv_0 \in X to vmYv_m \in Y if every adjacent pair is connected by a directed edge in either direction.

For each interior node viv_i with 1im11 \le i \le m-1, inspect the triple

vi1,vi,vi+1.v_{i-1}, v_i, v_{i+1}.

The middle node is a collider on this trail when both arrows point into it:

vi1vivi+1.v_{i-1} \to v_i \leftarrow v_{i+1}.

Otherwise it is a non-collider on the trail. Chains and forks are both non-collider cases for this purpose.

A trail is active given ZZ when every interior triple satisfies:

non-collider vi:viZ,\text{non-collider }v_i: \quad v_i \notin Z,

and

collider vi:viZordesc(vi)Z.\text{collider }v_i: \quad v_i \in Z \quad\text{or}\quad \operatorname{desc}(v_i)\cap Z \ne \emptyset.

The node sets XX and YY are d-separated by ZZ when no active trail connects them:

XGYZevery trail from X to Y is blocked by Z.X \perp_G Y \mid Z \quad\Longleftrightarrow\quad \text{every trail from }X\text{ to }Y\text{ is blocked by }Z.

For Bayesian networks, d-separation is sound:

XGYZXPYZX \perp_G Y \mid Z \quad\Rightarrow\quad X \perp_P Y \mid Z

for every distribution PP that factorizes over GG.

The reverse direction is not guaranteed for a particular parameterization. A distribution can contain extra numerical independencies that the graph does not encode. That is why the lab says "d-connected: no graph guarantee" rather than "definitely dependent."

03

03

Code

Keep the implementation aligned with the notation so the algorithm is legible.

Section prompt
edges = {("C", "S"), ("C", "R"), ("S", "W"), ("R", "W"),
         ("R", "T"), ("W", "L"), ("T", "L")}
nodes = "C S R W T L".split()
children = {n: [b for a, b in edges if a == n] for n in nodes}

def descendants(n):
    out, stack = set(), list(children[n])
    while stack:
        x = stack.pop()
        if x not in out:
            out.add(x)
            stack += children[x]
    return out

def adjacent(a, b):
    return (a, b) in edges or (b, a) in edges

def triple_kind(a, b, c):
    if (a, b) in edges and (c, b) in edges:
        return "collider"
    return "non-collider"

def active_path(path, observed):
    observed = set(observed)
    for a, b, c in zip(path, path[1:], path[2:]):
        if not adjacent(a, b) or not adjacent(b, c):
            return False
        if triple_kind(a, b, c) == "collider":
            if b not in observed and not (descendants(b) & observed):
                return False
        elif b in observed:
            return False
    return True

tests = [
    ("fork blocked", ["S", "C", "R"], {"C"}),
    ("collider observed", ["S", "W", "R"], {"C", "W"}),
    ("descendant opens", ["S", "W", "R"], {"C", "L"}),
]
for name, path, z in tests:
    print(name, active_path(path, z))

The code is a tiny teaching version of what graph libraries implement more generally. For production graph analysis, NetworkX exposes d-separation utilities such as is_d_separator for DAGs, but the hand-written version keeps the chain/fork/collider mechanism visible.

04

04

Interactive Demo

Use direct manipulation to connect the explanation to a moving system.

Section prompt

The lab below reuses the Bayesian Networks DAG. Pick the query and evidence case, predict whether the graph guarantees independence, then reveal every trail between the query nodes. The ledger stays locked until you commit, so you have to reason from the graph before seeing the active path.

Live Concept Demo

Explore d-Separation

The stage is code-native and interactive. Use it to test the explanation against the mechanism.

difficulty 4/5graduatecode-aligned
Demo Prediction Checkpoint

Manipulate one control and predict the visible change.

Commit to what d-Separation 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

d-Separation is the graph test that says which conditional independencies a Bayesian-network DAG guarantees after evidence is observed.

Prediction open01 / Intuition
Prediction lens

Start with the picture, metaphor, or geometric mechanism.

Commit first

Before reading further, choose the kind of change d-Separation should make visible.

Visual Inquiry

Make the image answer a mathematical question

d-Separation is the graph test that says which conditional independencies a Bayesian-network DAG guarantees after evidence is observed.

4/4 stages readyLive demo connected
Prediction

Which visible object should carry the first intuition?

Commit first

Pick the cue that should make d-Separation easier to reason about before the page gives the answer.

Source Grounding

Canonical references for the mechanism on this page.

course-notes · 2026Stanford CS228 Notes: Bayesian NetworksStanford CS228

Grounds active paths, common-parent/chain/v-structure cases, descendants of colliders, and the I-map caveat.

Open source
course-notes · 2026Berkeley CS188 Textbook: D-SeparationUC Berkeley CS188

Supports the three canonical triples, the path-enumeration algorithm, and the wording that d-connected means not guaranteed independent.

Open source
book · 2022Probabilistic Machine Learning: An IntroductionKevin P. Murphy

Probabilistic-ML reference for graphical-model independence and inference context.

Open source
book · 2009Probabilistic Graphical Models: Principles and TechniquesDaphne Koller and Nir Friedman

Canonical PGM reference for the semantics and completeness limits of directed graphical-model independence maps.

Open source
documentation · 2026NetworkX Documentation: D-SeparationNetworkX

Official open-source graph-library reference for d-separation tests in DAGs and minimal d-separator utilities.

Open source

Claim Review

d-Separation is the graph test that says which conditional independencies a Bayesian-network DAG guarantees after evidence is observed.

Status1 substantive review recorded

Claims without a substantive review badge still need exact source-support review.

Sources5 references

cs228-d-separation, berkeley-cs188-d-separation, murphy-2022-probabilistic-ml, koller-friedman-2009-pgm, networkx-2026-d-separation

Local checks4 local checks

Use equations, runnable code, and demos to check whether the source support is operational.

Substantively reviewedIn a Bayesian-network DAG, two node sets are d-separated by observed nodes when every undirected trail between them is blocked; non-colliders are blocked when observed, while colliders open only when the collider or one of its descendants is observed.Claim metadata: source checked

The sources support the page's active-trail algorithm, the chain/fork/collider distinction, descendant-of-collider evidence, and the careful wording that d-separation gives an independence guarantee while d-connection only removes that graph-level guarantee.

Sources: Stanford CS228 Notes: Bayesian Networks, Berkeley CS188 Textbook: D-Separation, Probabilistic Machine Learning: An Introduction, Probabilistic Graphical Models: Principles and Techniques, NetworkX Documentation: D-SeparationFinite DAG teaching graph only; excludes do-calculus, causal identification, selection bias, latent confounding, cyclic graphs, Markov equivalence proofs, 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 active-path rules, descendant-of-collider opening, and the I-map soundness caveat; checked Berkeley CS188 for chain/common-cause/common-effect examples and the path-enumeration procedure; checked NetworkX docs for practical open-source d-separation APIs and the graph-only nature of the test. GPT Pro publication critique remains pending because 127.0.0.1:51672 is unavailable.

Reviewer: codex-local-source-review; reviewed 2026-07-02

Practice Loop

Try the idea before it explains itself

d-Separation is the graph test that says which conditional independencies a Bayesian-network DAG guarantees after evidence is observed.

Readiness0/3 checks ready
Predict

Before touching the demo, predict one visible change that should happen in d-Separation.

Hint 1

Reveal when your model needs a nudge.

Hint 2

Reveal when your model needs a nudge.

Hint 3

Reveal when your model needs a nudge.

Grounded research drawerClose
Conceptd-SeparationProbability

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.
Next local actionNo local draft saved yet

Open the draft below to save one note and next action in this browser.

conceptProbability

d-Separation

Attached question

What is the smallest example that makes d-Separation click without losing the math?

Local action draftNo local draft saved yetExpand only when ready to capture one local next action
Local action draft

This draft stays in this browser, attached to the selected learning item.

No local draft saved.
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
Grounded AI handoff

I am working in Continuous Function's research reading room. Object: concept - d-Separation Selected item key: recorded for copy. Context: Probability Page anchor: recorded for copy. Open question: What is the smallest example that makes d-Separation 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.

View it in context
concept/concept-notebook/probability/d-separation concept:probability/d-separation