Probability · foundations Section 1.3 · item 2 of 33

Conditional
probability

Learning something true doesn't change the world. It changes which part of the world you're still standing in. Conditioning is that move: throw away every outcome inconsistent with what you now know, then rescale what's left so it adds to one again.

Two operations, always in that order — restrict, then renormalize. Almost every mistake people make with conditional probability is forgetting the second one, or restricting to the wrong set.

The definition

P(A | B) = P(AB)P(B)

The numerator restricts: outcomes where both happen. The denominator renormalizes: the new total. Requires P(B) > 0 — you cannot condition on something impossible.

Drag the world apart

The square is every possible outcome, total area 1. The vertical line splits it by whether B happened. Each column is then split by whether A happened. Drag all three lines, and switch what's highlighted to see which region each probability is actually asking about.

P(A | B)
P(B | A)
P(A) P(B) P(A ∩ B) P(A | ¬B) independent?
01The definition

Restrict, then renormalize

Before you know anything, the sample space is everything that could happen. Learning that B occurred does something specific and mechanical: every outcome outside B is now impossible, so you delete it. But the surviving outcomes no longer sum to 1, so you divide them all by how much survived.

Before conditioning · after conditioning on B
P(A | B) = P(AB)P(B)
numerator
The part of A that survived the restriction — outcomes where both A and B happen.
denominator
How much of the original space survived. This is the renormalization, and forgetting it is the most common error.
P(B) > 0
Required. Conditioning on an impossible event is undefined — there is nothing left to renormalize against.
The subtlety worth internalizing. Conditioning does not change reality; it changes your reference class. P(A | B) is not "the probability of A after B caused something." It is the proportion of B-outcomes that are also A-outcomes. No causation is implied anywhere in the definition.

A conditional is still a probability

Fix B and P(· | B) obeys every axiom: it's non-negative, P(Ω | B) = 1, and it adds over disjoint events. Everything you know about probability applies unchanged inside the restricted world.

The unconditional is conditional too

P(A) is really P(A | everything you already assume) — the sample space, the model, the population. There is no such thing as a probability without a reference class; some are just left implicit.

Conditioning can go either way

Learning B can raise P(A), lower it, or leave it alone. All three are ordinary. The third case has a name — independence — and gets section 04.

02Reading it

Which side of the bar?

Most errors in applied probability are translation errors — turning an English sentence into the wrong conditional. The fix is a habit: identify the reference class first, because that's what goes to the right of the bar.

EnglishReference classNotation
"Of the patients who tested positive, how many are ill?"Positive testersP(ill | positive)
"Of the ill patients, how many test positive?"Ill patientsP(positive | ill)
"Among smokers, the rate of X is…"SmokersP(X | smoker)
"Given that it rained, …"Rainy daysP(· | rain)
"If the coin is fair, the chance of …"Fair-coin worldsP(· | fair)
"The false positive rate"Healthy peopleP(positive | healthy)
"The chance this positive is a false alarm"Positive testersP(healthy | positive)
"X% of accidents involve Y"AccidentsP(Y | accident)
"Y raises accident risk by X%"People with YP(accident | Y)
Note the fourth and fifth pairs. Each pair uses nearly the same words and means opposite things. "The false positive rate is 5%" and "5% of positives are false" are entirely different claims, and which one is true can differ by two orders of magnitude. Section 06 is about exactly this.
A reliable trick. Rewrite any conditional as "out of all the ___, what fraction are ___?" If you can't fill the first blank confidently, you don't yet know what's being asked — and neither does whoever wrote the sentence.
03Chain rule

The same equation, rearranged

Multiply the definition through by the denominator and you get the multiplication rule — a way to build joint probabilities out of conditionals. This rearrangement is quietly one of the most useful facts in machine learning.

Multiplication rule

P(AB) = P(A | B) · P(B)
also = P(B | A) · P(A)

Two decompositions of the same joint probability. Setting them equal to each other and dividing gives Bayes' theorem in one line — see section 08.

Chain rule

P(A1An) = ∏i P(Ai | A1Ai−1)

Apply the multiplication rule repeatedly and any joint distribution over any number of variables factorizes into a product of conditionals — each one conditioned on everything before it. The factorization is exact, always, with no assumptions.

This is what a language model is. The probability of a sentence is the joint probability of its tokens, which the chain rule factorizes into "probability of each token given everything before it." Training a model to predict the next token is not an approximation of language modeling — by the chain rule, it is language modeling. The same factorization underlies autoregressive image models, Bayesian networks, and every sequential generative process.
# the chain rule, made literal
P("the", "cat", "sat") = P("the")
                     × P("cat" | "the")
                     × P("sat" | "the", "cat")

# an n-gram model truncates the history — an approximation
P("sat" | "the", "cat") ≈ P("sat" | "cat")

# a transformer keeps all of it, up to the context window — no truncation
04Independence

When knowing changes nothing

Independence is the special case where conditioning is a no-op. Learning B leaves your belief about A exactly where it was.

Three equivalent statements

P(A | B) = P(A)
P(B | A) = P(B)
P(AB) = P(A) · P(B)

Any one implies the other two. The third is usually taken as the formal definition because it's symmetric and stays valid when a probability is zero.

In the hero square, independence is exactly when the two horizontal dividers line up — the split of A is the same whichever column you're in. Try the "make independent" preset and watch them level.

Independent · mutually exclusive · not the same thing
Independent and mutually exclusive are opposites, not synonyms. If A and B are mutually exclusive with non-zero probabilities, then learning B tells you A definitely did not happen — P(A | B) = 0. That is maximal dependence. Disjoint events are about as far from independent as it's possible to get, and the words sounding similar has cost a great many exam marks.

Pairwise ≠ mutual

Three events can be independent in every pair and still not jointly independent. The classic case: two fair coin flips plus the event "the flips matched." Any two of those three are independent; all three together are not, because any two determine the third completely.

Independence is an assumption, not an observation

It is almost never verified in practice — it's assumed because it makes the maths tractable, and the assumption is usually somewhat false. Knowing which independence assumptions your model makes is knowing where it will fail.

05Conditional independence

Independent once you know something else

The more useful and more subtle relative. A and B may be strongly dependent overall, yet become independent once you fix a third variable C.

P(AB | C) = P(A | C) · P(B | C)

The common-cause case

Ice cream sales and drowning deaths are strongly correlated. Condition on the temperature and the correlation vanishes — each was driven by the season, not by the other. C explains the dependence, and once you hold it fixed, nothing is left.

This is the entire idea behind naive Bayes. It assumes every feature is conditionally independent of every other given the class label. Wildly false in general — and the classifier often works anyway, because picking the argmax survives badly miscalibrated probabilities.
Chain · fork · collider — conditioning behaves differently in each
Conditioning can also create dependence, and this surprises people. Suppose a school admits students who are either strong academically or strong athletically. In the general population the two abilities are independent. Among the admitted students they become negatively correlated — if someone got in and isn't a good athlete, they must be academically strong. Nothing caused anything; conditioning on a common effect manufactured the association. This is called explaining away or collider bias, and it's how careless "controlling for" variables introduces bias rather than removing it.
StructureShapeUnconditionallyConditioning on C
ChainA → C → BDependentBlocks the path — becomes independent
Fork · common causeA ← C → BDependentBlocks the path — becomes independent
Collider · common effectA → C ← BIndependentOpens the path — becomes dependent

These three rules are the whole of d-separation, which is how graphical models read independence relations straight off a diagram. "Control for everything you can" is bad advice precisely because of row three.

06The inversion

P(A | B) is not P(B | A)

The most consequential fact in this document. These two numbers can differ enormously, and confusing them has sent people to prison and sent patients into unnecessary treatment. The unit square makes it obvious why: one is a fraction of a column, the other a fraction of a band.

A test for a rare condition

0.10%
99.0%
99.0%
P(ill | tested positive)
P(positive | ill) — sensitivity
Per 10,000 people tested
Why the answer feels wrong. At the default settings the test is 99% accurate in both directions, and yet a positive result means you probably don't have the condition. The reason is that healthy people vastly outnumber ill ones, so even a small false positive rate produces a large false positive count. Rate and count are not the same, and intuition tracks the rate.
Base rate neglect. People — including doctors, in repeated studies — tend to answer this question with the sensitivity, ignoring prevalence entirely. Drag prevalence upward and watch how completely it drives the answer while sensitivity barely moves it.
The prosecutor's fallacy. "The chance of this DNA match occurring by coincidence is one in a million, therefore the defendant is almost certainly guilty." The first number is P(match | innocent). The claim treats it as P(innocent | match). In a database of ten million people, a one-in-a-million coincidence rate produces roughly ten innocent matches — and the inference collapses.
The fix is natural frequencies. Recast every such problem as counts out of a concrete population, exactly as the diagram above does. "Out of 10,000 people, 10 are ill and 9 of those test positive, while 100 healthy people also test positive" makes the answer nearly automatic. The same information in percentages defeats most people, including trained ones.
07Total probability

Building the whole from the cases

If you can carve the world into cases that don't overlap and cover everything, then the overall probability of anything is the weighted average of its probability within each case.

P(A) = ∑i P(A | Bi) · P(Bi)
Multiply along branches · add across them

The two rules that make trees work: multiply along a path because each step is a conditional given the ones before it, and add across paths because the leaves are mutually exclusive. Every leaf is a joint probability, and they sum to 1.

In the hero square, this is just the observation that the total A area is the left A rectangle plus the right A rectangle — each one a conditional height times a column width.

Marginalization is the same operation. Summing a joint distribution over one variable to get the distribution of another is exactly this rule. In continuous form the sum becomes an integral, and it is the step that makes Bayesian inference computationally hard — that denominator integral rarely has a closed form, which is why MCMC and variational methods exist.
08Toward Bayes

The inversion, derived in two lines

Bayes' theorem gets its own entry in the checklist, but it isn't a new idea — it's the definition of conditional probability written twice and rearranged. Worth seeing that it costs nothing to derive.

P(AB) = P(A | B) P(B)   and   P(AB) = P(B | A) P(A)
⇒   P(A | B) P(B) = P(B | A) P(A)
⇒   P(A | B) = P(B | A) · P(A)P(B)

That's it. The theorem is a bookkeeping identity. What makes it philosophically interesting is the interpretation laid on top: P(A) as a prior belief, P(B | A) as how well the hypothesis predicts the evidence, and P(A | B) as the updated belief.

Read it as a correction factor. The posterior equals the prior times P(B | A) / P(B) — how much more likely the evidence is under your hypothesis than in general. If the evidence is no more expected under A than otherwise, that ratio is 1 and nothing updates. Evidence only moves you when it discriminates.
09Traps

Where intuition reliably fails

Monty Hall

Three doors, one prize. You pick one. The host — who knows where the prize is and will always open a losing door — opens one of the others. Switching wins two times in three.

The resolution is that the host's action is constrained, so it carries information. Your original door was right 1/3 of the time and that never changes; the remaining 2/3 gets concentrated onto the single unopened door. Change the rule so the host opens a door at random and might reveal the prize, and switching becomes worthless. The conditioning depends on the protocol, not just the outcome.

Two children

"A family has two children. At least one is a boy. What's the chance both are?" The textbook answer is 1/3 — of the four equally likely orderings, three contain a boy, and one of those is two boys.

But it depends entirely on how you learned it. If you met one child at random and he was a boy, the answer is 1/2. Same words, different sampling process, different conditioning set. This problem is famous less as a puzzle than as a demonstration that you cannot condition on a statement — only on an event, and the event includes how the information reached you.

Simpson's paradox

A treatment can have a higher success rate in every subgroup and a lower success rate overall. Not a trick — a genuine arithmetic possibility, arising when group sizes are unequal and the grouping variable also influences the outcome.

The famous real case is the 1973 Berkeley graduate admissions data, where the university-wide rate favoured men while most individual departments favoured women — because applicants sorted unevenly across departments with very different competitiveness. The paradox is that neither number is wrong. They answer different questions, and deciding which to report is a causal judgement, not a statistical one.

Selection bias is conditioning you didn't choose. Every dataset is already conditioned on how it was collected — who responded, what got logged, which patients reached the clinic, which trials were published. You are never computing P(A); you are computing P(A | in my data). Whether that's close enough to what you wanted is the question that decides whether the analysis means anything.
10In machine learning

Where it actually shows up

WhereThe conditionalWhat it means
ClassificationP(y | x)Literally the model's output. A classifier is a conditional distribution over labels given features
Discriminative modelsP(y | x)Logistic regression, most neural nets — model the conditional directly
Generative modelsP(x | y) P(y)Naive Bayes, GDA — model how each class generates data, then invert with Bayes
Naive Bayes∏ P(xⱼ | y)The conditional independence assumption, stated as a product
Language modelsP(wₜ | w₁…wₜ₋₁)The chain rule factorization of a sentence's joint probability
Cross-entropy loss−log P(y | x)The training objective is the negative log of a conditional probability
Graphical modelsConditional independenceThe graph structure is a set of conditional independence claims
Reinforcement learningP(s' | s, a)Transition dynamics — the next state given the current state and action
VAEsq(z | x), p(x | z)Encoder and decoder are both conditional distributions
Diffusion modelsp(xₜ₋₁ | xₜ)Each denoising step is a conditional
Causal inferenceP(Y | X) vs P(Y | do(X))Observing versus intervening — different quantities, and only the second answers "what if we acted"
Fairness criteriaP(ŷ | y, group)Most fairness definitions are statements about conditionals holding across groups
The one to sit with is the last row but one. P(recovery | took the drug) is what the data shows. P(recovery | we give the drug) is what you need to make a decision. They differ whenever the people who took it differ from the people who didn't — which is nearly always in observational data. Conditional probability describes the world as it sorted itself; it does not, by itself, tell you what happens when you intervene.
11Practice

Drills that build the instinct

#Do thisYou'll know it when
1For every conditional you meet this week, say out loud "out of all the ___, what fraction are ___"You catch a reversed conditional in someone else's writing
2Work the medical test problem with pen and paper at three prevalences before touching the sliderYou can predict roughly where PPV lands without computing it
3Build a 2×2 contingency table from counts and compute all four conditionals plus both marginalsYou stop needing the formula and just read the table
4Simulate Monty Hall 10,000 times in ten lines of codeThe 2/3 stops feeling like a trick
5Construct a dataset that exhibits Simpson's paradox from scratchYou understand it as arithmetic rather than as a curiosity
6Simulate collider bias — two independent variables, condition on their sum being largeYou've seen conditioning manufacture a correlation from nothing
7Write the chain rule factorization of a five-word sentence by handThe link between conditioning and language modeling is concrete
8Take one published statistic and identify its implicit reference classYou notice how often the reference class is unstated or wrong

The one-paragraph summary

Conditional probability is the operation of restricting the sample space to the outcomes consistent with what you've learned, then renormalizing so the survivors sum to one — which is exactly what P(A | B) = P(A ∩ B) / P(B) says. Rearranged, it gives the multiplication rule and hence the chain rule, which factorizes any joint distribution into a product of conditionals and is the reason next-token prediction constitutes language modeling. Independence is the case where conditioning changes nothing, and it is emphatically not the same as mutual exclusivity. Conditional independence — independence once a third variable is fixed — is the more useful notion, underpinning naive Bayes and graphical models, and it comes with the warning that conditioning on a common effect creates dependence rather than removing it. The single most costly error is confusing P(A | B) with P(B | A), which base rates can separate by orders of magnitude; recasting the problem as counts out of a concrete population is the most reliable defence. And every dataset is already conditioned on how it was collected, so the quantity you compute is never quite the quantity you wanted.