Most real questions involve two things at once: age and churn, symptom and
disease, word and spam. Once there are two attributes, there are three
different questions you can ask, and they have three different answers.
Picture a table of 100 people split by whether they exercise and whether they
sleep well.
Joint: pick one person at random — what is the chance they exercise and
sleep well? That is one cell of the table divided by 100.
Marginal: what is the chance they exercise, ignoring sleep entirely? That is
a whole row total divided by 100.
Conditional: given that they exercise, what is the chance they sleep well?
That is one cell divided by its row total — you have thrown away everyone
who does not exercise.
The only mechanical difference is what you divide by. Get the denominator right
and conditional probability stops being confusing.
Notation used in this lesson
Symbol
Meaning
Read aloud
P(A ∩ B)
Joint: both A and B occur
P of A and B
P(A)
Marginal: A occurs, regardless of B
P of A
P(A | B)
Conditional: A occurs, given B occurred
P of A given B
P(A, B)
Alternative notation for the joint probability
P of A comma B
A worked table
A survey of 100 people records exercise habit and sleep quality.
Sleeps well
Sleeps badly
Row total
Exercises
35
15
50
Does not
15
35
50
Column total
50
50
100
Let E = "exercises" and W = "sleeps well".
Joint probabilities — cells ÷ grand total
P(E∩W)=10035=0.35
Each of the four cells gives a joint probability, and the four sum to 1:
0.35+0.15+0.15+0.35=1✓
Marginal probabilities — totals ÷ grand total
P(E)=10050=0.5,P(W)=10050=0.5
The word marginal is literal: these are the numbers written in the margins
of the table.
Marginals are obtained from joints by summing over the variable you want to
discard:
P(E)=P(E∩W)+P(E∩Wc)=0.35+0.15=0.5
Conditional probabilities — cell ÷ row or column total
P(W∣E)=5035=0.7
Among the 50 people who exercise, 35 sleep well. The denominator changed from 100
to 50 because conditioning on E discards everyone outside E.
The definition of conditional probability
P(A∣B)=P(B)P(A∩B),P(B)>0Where the formula comes fromAdvanced
Conditioning on B means restricting the sample space to B — we now treat B
as the whole world. Within that restricted world, the outcomes favourable to A
are exactly those in A∩B.
For equally likely outcomes this is transparent:
P(A∣B)=∣B∣∣A∩B∣
Divide numerator and denominator by ∣Ω∣:
P(A∣B)=∣B∣/∣Ω∣∣A∩B∣/∣Ω∣=P(B)P(A∩B)
The general definition is taken to be this ratio, which reduces to the counting
version when outcomes are equally likely. Dividing by P(B) is precisely what
re-normalises the restricted world so its probabilities sum to 1 again.
Check with the table:
P(W∣E)=P(E)P(E∩W)=0.50.35=0.7✓
The multiplication rule
Rearranging the definition gives a rule for building joints out of conditionals:
P(A∩B)=P(A∣B)P(B)=P(B∣A)P(A)
Both forms are valid, which is the seed of Bayes' theorem two lessons from now.
Extended to three events (the chain rule):
P(A∩B∩C)=P(A)P(B∣A)P(C∣A∩B)
Conditioning is not symmetric
P(A∣B) and P(B∣A) are different quantities. From the table:
P(W∣E)=5035=0.70,P(E∣W)=5035=0.70
Here they coincide, but only because the margins happen to be equal. Change the
table so 80 people exercise and 20 do not, keeping P(E∩W)=0.35:
P(W∣E)=0.800.35=0.4375,P(E∣W)=0.500.35=0.70
Solved problem 1 · Reading all three from one table
A shop classifies 200 visits by whether the visitor used a mobile device and
whether they purchased.
Purchased
Did not
Total
Mobile
24
96
120
Desktop
32
48
80
Total
56
144
200
Let M = mobile, B = purchased. Find the joint, both marginals, and both
conditionals. Are M and B independent?
Step 1 — joint probability
P(M∩B)=20024=0.12
Step 2 — marginals from the totals
P(M)=200120=0.60,P(B)=20056=0.28
Step 3 — conversion rate on mobile
P(B∣M)=P(M)P(M∩B)=0.600.12=0.20
Directly from the table: 24/120=0.20 — 20% of mobile visits convert.
Step 4 — share of purchasers who were on mobile
P(M∣B)=P(B)P(M∩B)=0.280.12≈0.4286
Directly: 24/56≈0.4286 — about 43% of purchasers came from mobile.
Note how different these two numbers are (0.20 versus 0.43) despite sharing the
same numerator. They answer different questions.
Step 5 — test independence
P(M)P(B)=0.60×0.28=0.168P(M∩B)=0.12=0.168
Not independent. Compare the conditional with the marginal:
P(B∣M)=0.20<P(B)=0.28
Mobile visitors convert at 20% against a 28% baseline, so device type carries
genuine information about purchasing.
Answer
P(M∩B)=0.12; P(M)=0.60; P(B)=0.28;
P(B∣M)=0.20; P(M∣B)≈0.429. The events are
not independent — mobile visitors convert below the overall rate.
Solved problem 2 · Drawing without replacement
An urn holds 5 red and 3 blue balls. Two are drawn without replacement. Find the
probability that both are red.
Step 1 — name the events
Let R1 = first ball red, R2 = second ball red. We want
P(R1∩R2).
Step 2 — the first draw
P(R1)=85
Step 3 — the second draw, conditioned on the first
After removing one red ball, 7 balls remain of which 4 are red:
P(R2∣R1)=74
This conditional differs from P(R2), which is what "without replacement"
means — the draws are dependent.
All three axioms hold, so every theorem proved for P also holds for
P(⋅∣B). This is why you may freely use the complement rule and
inclusion–exclusion inside a conditional.
Exercise 1
From the shop table, compute P(B∣Mc) — the desktop conversion rate —
and confirm that the two conditional rates, weighted by their marginals, recover
P(B).
This weighted-average identity is the law of total probability, covered in the
next lesson.
Exercise 2
A family has two children. Given that at least one is a girl, what is the
probability both are girls? Assume each child is independently a girl with
probability 1/2.
Show solutionHide solution
Sample space with birth order: Ω={GG,GB,BG,BB}, each of probability
1/4.
Let A = "at least one girl" ={GG,GB,BG} and C = "both girls"
={GG}.
P(C∣A)=P(A)P(C∩A)=3/41/4=31
Not 1/2. Conditioning on "at least one" eliminates only BB, leaving three
equally likely cases, of which one is GG.
The common wrong answer, 1/2, comes from imagining a specific child is a girl.
That is a different condition: "the elder is a girl" restricts to
{GG,GB} and does give 1/2.
Exercise 3
Show that if P(A∣B)>P(A), then P(B∣A)>P(B).
Show solutionHide solution
Start from the assumption and substitute the definition:
P(B)P(A∩B)>P(A)
Multiply both sides by P(B)>0:
P(A∩B)>P(A)P(B)
Now divide both sides by P(A)>0:
P(A)P(A∩B)>P(B)⟹P(B∣A)>P(B)
So "positive association" is symmetric: if B raises the chance of A, then A
raises the chance of B — even though the two conditional probabilities
themselves are generally different numbers.
Next: The Law of Total Probability,
which formalises the weighted-average trick from Exercise 1 and is the direct
prerequisite for Bayes' theorem.