TL;DR
Two events or variables can be independent on their own and still tell you a lot about each other once a third quantity is known. Conditional independence is the statement that, once you fix that third quantity , the two variables and become independent of each other. It is written . It is the tool that lets a model with many variables be described by a short list of local rules instead of one enormous joint table.
Builds on: Statistical Independence, Conditional Probability · Leads to: Bayes' Rule in models with several symptoms or signals, and the graphical models that organise them
Where it's used
Diagnosis with several symptoms. A doctor who sees fever and a cough in a patient must reason about both. Once the doctor knows whether the patient has the flu, the two symptoms are often treated as separate signs of the same cause. The model then needs only the chance of each symptom given flu and given no flu, instead of the chance of every combination of symptoms. This lesson explains the probability idea only and gives no medical advice.
Spam filters. A classic spam filter treats the words in an email as conditionally independent given whether the email is spam. The assumption is rarely true in real text, but it makes the model simple, and simple models often classify well. The method is known as naive Bayes.
Speech and sequences. A hidden Markov model used in speech recognition assumes that the next sound depends only on the current hidden state. Given the present state, the future is conditionally independent of the past. That single statement is what makes the computation feasible for sentences of any length.
How it works
Take two coins chosen from a bag. The bag holds two coins: coin A always lands heads, and coin B always lands tails. You pick one coin at random, each with chance 1/2, and flip it twice. Let be the coin you picked, and let and be the events that the first and second flips are heads.
- Given , the flips do not affect each other. If the coin is A, both flips are heads with certainty. If it is B, both are tails. Check: once you know the coin, nothing about the first flip changes what the second flip will be.
- Ask what happens if you do not know the coin. The chance of heads on the first flip is 1/2 times 1 (coin A) plus 1/2 times 0 (coin B), so . Check: a half-half mix of always-heads and always-tails coins gives heads half the time.
- The chance of heads on both flips is also 1/2 times 1 plus 1/2 times 0, which is . Check: the two flips agree, so both heads happen on exactly the same coin choices as one head.
- Compare with independence. If and were independent, the chance of both would be . But it is . Check: is larger than , so the flips are not independent without knowing the coin.
- Now condition on the coin. Given coin A, . The same holds for coin B. So . Check: once the coin is fixed, the product rule works in both cases.
The diagram shows the structure of this mixture of two cases. The coin is a common cause of both flips, and once it is known, the arrows from it are the only paths that matter.
flowchart TD Z["Coin Z (A or B)"] --> H1["First flip H1"] Z --> H2["Second flip H2"]
The math
Events, or random variables, and are conditionally independent given when, for each value of ,
We write . Here is the conditional probability of in the world where equals .
Step 2 in symbols: the marginal chance
Let the coin be , with . Splitting on the coin is the law of total probability:
Step 3 in symbols: the joint chance
The same splitting gives the chance of both heads:
Step 4 in symbols: marginal dependence
If the flips were independent, would equal . Because it equals , the two flips are dependent without the coin being known. In general,
Mixing two cases, each with a clean product rule, does not in general give a clean product rule.
Step 5 in symbols: the conditional product
Given , the product rule holds: . The same holds given . That is the definition above, so .
A useful equivalent form is . Learning adds nothing about once is known. The joint distribution of three variables then factorises as
which is far fewer numbers to store than the full joint table.
Worked examples
Take coin A that always lands heads, and coin B that always lands tails. You pick one at random, with chance 1/2 each. Let be heads on the first flip and heads on the second.
- Find : .
- Find .
- Find .
- Compare: , so the flips are dependent.
- Given coin A, , so given the coin the flips are independent.
The flips are dependent overall and independent given the coin. The coin is the hidden common cause that links them.
Each coin is chosen with chance 1/2. Coin A lands heads with chance 0.9, and coin B lands heads with chance 0.1. Each flip is independent of the others once the coin is fixed. Find and , and check the conditional product rule.
- Given coin A, the flips are independent, so .
- Given coin B, .
- Average over the coin: .
- Find , and similarly .
- Compare: , which is less than 0.41. The flips are dependent overall.
- Given coin A, , which matches step 1. The conditional product rule holds.
Knowing that the first flip was heads makes the coin more likely to be A, so it makes a second heads more likely. Once the coin is known, that link disappears.
Let be the event that a patient has flu, with . Given , let fever and cough be conditionally independent, with and . Given not , and . Find , the chance of both symptoms, and compare it with .
- Given flu, the chance of both symptoms is . Multiply by : .
- Given no flu, the chance of both is . Multiply by : .
- Add the two parts: .
- Find , and .
- Multiply: .
- Compare: is almost twice , so fever and cough are dependent overall. Both are signs of flu, so seeing one raises the chance of the other.
Try it: Find and say whether fever and cough are independent in the group of patients without flu.
Answer: , and . They match, so within that group the symptoms are independent, as conditional independence given predicts.
Common mistakes and tradeoffs
It is tempting to think that conditional independence means plain independence. In fact says nothing about and on their own. In the coin example the flips are conditionally independent given the coin but dependent overall, because the coin links them.
It is tempting to think the reverse holds too: that independent variables stay independent once a third is known. In fact conditioning can create dependence. Take two fair coins and , which are independent, and let when they match. Given , knowing tells you exactly, so and are dependent given .
It is tempting to think that a model with independence assumptions is always accurate. In fact such assumptions are simplifications. Real symptoms or words are often correlated even given the cause. Naive Bayes is used because it is simple and often good enough, not because the assumption is true.
Use conditional independence when a model has a clear common cause or a Markov structure, because it cuts the number of parameters sharply. Avoid it when the variables interact directly, or when the data show clear dependence after conditioning. Alternatives include modelling the full joint distribution, adding explicit links between variables, or using a Markov chain when the order of events matters.
History
In the eighteenth century Thomas Bayes and Pierre-Simon Laplace worked out how to reason from evidence to hypotheses. The idea of treating variables as conditionally independent given a cause was used in early statistics and in practical classifiers, which were later called naive Bayes.
Its full power arrived in the 1980s. Judea Pearl showed that a set of conditional independence statements can be drawn as a graph, and that the graph tells you how evidence flows through a model. His 1988 book Probabilistic Reasoning in Intelligent Systems made these graphical models, now called Bayesian networks, a standard tool in artificial intelligence.
It caught on because it turned an impossible joint table into a manageable set of local rules. A model with thirty binary variables has about a billion entries in its full joint table, while a sparse set of conditional independences may need only a few hundred numbers.
Recap
- Two variables are conditionally independent given when .
- Conditional independence does not imply independence, and independence does not imply conditional independence.
- Conditioning on a common cause can remove dependence; conditioning on a common effect can create it.
- The factorisation is the payoff, because it needs far fewer numbers than the full joint table.
- Read next: Bayes' Rule, where these factorised models are used to update beliefs from evidence.
Check yourself
QuestionState the definition of in words and as a formula.Show answer
and are conditionally independent given when, for each value of , the probability of both and equals the product of their separate probabilities given that value: . Once is known, learning one tells you nothing more about the other.
QuestionIn the coin example, and . Explain in one sentence why these two numbers show the flips are dependent.Show answer
If the flips were independent, the chance of both heads would be , but it is . The two flips agree because they use the same coin, so the outcomes are linked.
QuestionA coin lands heads with chance 0.7 when it is coin A and 0.3 when it is coin B, and each coin is chosen with chance 1/2. Given coin A, two flips are independent. Find and .Show answer
Given coin A, . Given coin B, . Averaging over the coin gives .
QuestionWhy would a spam filter that treats words as conditionally independent given the spam label still be useful, even though words in real emails are correlated?Show answer
The assumption makes the model simple: it needs only the chance of each word given spam and given not spam, which are easy to estimate from labelled emails. The model does not need to store the chance of every combination of words. Its accuracy depends on whether the simplification keeps the decisions right, which it often does, even though the assumption is not exactly true.