Math & Statistics

Conditional Independence

When two dependent variables become completely independent once a third confounding variable is observed.

🟡 intermediate4 min readprobability
Two random variables X and Y are conditionally independent given Z (denoted X ⊥ Y | Z) if P(X, Y | Z) = P(X | Z) P(Y | Z). Knowledge of Y provides zero additional information about X once Z is already known. Conditional independence simplifies joint probability distributions, enabling Naive Bayes classifiers, Bayesian Networks (DAGs), and Causal Inference d-separation algorithms.

Core Definition & Factorization

Two variables XX and YY are conditionally independent given ZZ (written X⊥Y∣ZX \perp Y \mid Z) if and only if:

P(X,Y∣Z)=P(X∣Z)P(Y∣Z)P(X, Y \mid Z) = P(X \mid Z) P(Y \mid Z)

Equivalently:

P(X∣Y,Z)=P(X∣Z)andP(Y∣X,Z)=P(Y∣Z)P(X \mid Y, Z) = P(X \mid Z) \quad \text{and} \quad P(Y \mid X, Z) = P(Y \mid Z)

Knowing YY gives zero extra information about XX when ZZ is already observed.

   Spurious Association (X <---> Y)        Conditioning on Z Breaks the Link!
              [ Z ]                                      [ Z ] (Observed)
             /     \                                    /     \
            ▼       ▼                                  ▼       ▼
          [ X ]   [ Y ]                              [ X ] ┴ [ Y ] (X ⊥ Y | Z)

Independence vs Conditional Independence

Classic Example: Common Cause (Fork)

XX and YY are correlated marginally (P(X,Y)≠P(X)P(Y)P(X, Y) \neq P(X)P(Y)). But conditioned on location setting ZZ, X⊥Y∣ZX \perp Y \mid Z.

Applications in Machine Learning

  1. Naive Bayes Classifier: Assumes all features X1,…,XdX_1, \dots, X_d are conditionally independent given class label YY:
P(X1,…,Xd∣Y)=∏i=1dP(Xi∣Y)P(X_1, \dots, X_d \mid Y) = \prod_{i=1}^d P(X_i \mid Y)

Converts exponential O(Kd)O(K^d) parameter space into linear O(d⋅K)O(d \cdot K) space!

  1. Bayesian Networks & Markov Blankets: A node XX in a Directed Acyclic Graph (DAG) is conditionally independent of all non-descendants given its parents.
  2. Causal Inference (d-separation): Blocking confounders ZZ isolates true causal effects X→YX \to Y.

Say this out loud

"Conditional independence X ⊥ Y | Z means P(X,Y|Z) = P(X|Z)P(Y|Z). Once Z is known, Y provides zero additional information about X. Spurious correlations between features often disappear when conditioning on a common cause Z. Naive Bayes relies on conditional independence of features given class Y to factorize high-dimensional joint likelihoods into simple 1D probability multiplications."

Follow-ups to expect

Check yourself

Question 1 of 3

What is the formal probability condition for X and Y to be conditionally independent given Z?

More in Math & Statistics

See all →
Bayes’ Theorem4 minCentral Limit Theorem4 minLaw of Large Numbers4 min