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 $X$ and $Y$ are conditionally independent given $Z$ (written $X \perp Y \mid Z$) if and only if:

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

Equivalently:

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

Knowing $Y$ gives zero extra information about $X$ when $Z$ 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)

$X$ and $Y$ are correlated marginally ($P(X, Y) \neq P(X)P(Y)$). But conditioned on location setting $Z$, $X \perp Y \mid Z$.

Applications in Machine Learning

  1. Naive Bayes Classifier: Assumes all features $X_1, \dots, X_d$ are conditionally independent given class label $Y$:

$$P(X_1, \dots, X_d \mid Y) = \prod_{i=1}^d P(X_i \mid Y)$$

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

  1. Bayesian Networks & Markov Blankets: A node $X$ in a Directed Acyclic Graph (DAG) is conditionally independent of all non-descendants given its parents.
  2. Causal Inference (d-separation): Blocking confounders $Z$ isolates true causal effects $X \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