Conditional independence

A building has a smoke detector and a sprinkler system. Over the past year, the smoke detector and sprinklers activated on many of the same days. Are they dependent?

What do you think?
The smoke detector and sprinklers both activated on the same days. Are these events dependent?

Dependence from a hidden cause

The smoke detector and sprinklers don't directly trigger each other. They both respond to a hidden common cause: fire.

  • When there's a fire, both are likely to activate (independently of each other)
  • When there's no fire, both are unlikely to activate (independently of each other)

Overall, they appear dependent. But within each "slice" — fire or no fire — they're independent.

Conditional Independence

Events A and B are conditionally independent given C if:

P(ABC)=P(AC)P(BC)P(A \cap B | C) = P(A|C) \cdot P(B|C)

Equivalently: P(ABC)=P(AC)P(A | B \cap C) = P(A | C). Once you know C, learning B tells you nothing new about A.

See it in the numbers

Toggle between "Everyone," "Given Fire," and "Given No Fire." Watch how the independence test changes.

Conditional Independence
Smoke detector (A) and sprinklers (B) — are they independent?
P(A∩B)
0.0100
P(A) · P(B)
0.0017
≈ Equal — conditionally independent (both triggered by hidden cause: fire)

The frequency table tells the same story with counts instead of probabilities.

Conditional Independence — Frequency Table
A = smoke detector, B = sprinklers, C = fire (hidden cause)
B (sprinklers)¬BTotal
A (smoke)375693
¬A22885907
Total599411000
P(A∩B)
0.0370
P(A) · P(B)
0.0055
≠ Not equal — dependent (confounded by fire)
What do you think?
Why are the smoke detector and sprinklers dependent overall, but independent given fire?

Independence does not imply conditional independence

This is where intuition breaks.

What do you think?
If A and B are independent (unconditionally), must they be conditionally independent given C?

A student is admitted to a university if they have either high test scores (A) or strong extracurriculars (B). A and B are independent in the population. But among admitted students (given C = admitted), they become negatively dependent: if an admitted student has low test scores, they probably have strong extracurriculars. Learning A tells you about B.

Four possible combinations

Marginally IndependentMarginally Dependent
Cond. Independent given CA and B ind.; also ind. given CSmoke/sprinkler: dependent overall, ind. given fire
Cond. Dependent given CAdmission: ind. overall, dep. given admittedA and B dep.; still dep. given C

All four boxes are possible. Independence and conditional independence are logically separate properties.

What do you think?
Coin flip A and coin flip B are independent. You're told A + B ≥ 1 (at least one head). Are A and B still independent given this information?

Why it matters

Conditional independence shows up constantly:

  • Naive Bayes classifiers assume features are conditionally independent given the class label
  • Markov chains assume future is conditionally independent of the past given the present
  • Bayesian networks encode which variables are conditionally independent of which

Getting conditional independence wrong leads to false confidence. A spam filter that assumes word occurrences are conditionally independent (given "spam" or "not spam") is wrong — "Nigerian" and "prince" are not conditionally independent in spam. But the approximation works surprisingly well.

A and B are conditionally independent given C. P(A|C) = 0.7, P(B|C) = 0.4. What is P(A ∩ B | C)? (decimal, e.g. 0.42)
1/3

Test your understanding

What condition makes A and B conditionally independent given C? (write the equation)
Naive Bayes assumes features X₁ and X₂ are _____ independent given the class Y. (one word)

What's next

You now have the full toolkit: conditional probability, the multiplication rule, LOTP, Bayes' Rule, independence, and conditional independence.

Time to deploy all of it on one of the most famous probability puzzles ever posed. The Monty Hall problem divided PhD mathematicians — and the answer hinges on exactly the conditional reasoning you've just learned.