25 November 2026 · 3 min readInteractive 3D
What is conditional probability? A visual guide
“Given that” is the most important phrase in probability. Light up one row of a 3D bar chart and see what it means.
The probability that a student scores well in physics is one thing. The probability they score well in physics given that they scored well in maths is another. That second kind, written P(A | B), is conditional probability.
From the whole table to one row
- The full set of bars shows the chance of every pair (X, Y). All 81 add up to 1.
- Choosing a value of X throws away every other row.
- Divide the lit bars by their total so they add up to 1 again.
- What remains is P(Y | X): the chances for Y, once you know X.
Why it matters
A language model is one giant conditional probability machine: the chance of the next word given all the words so far. Medical tests, spam filters and weather forecasts all reason the same way, updating chances as new information arrives.
Increase “how linked X and Y are”. Now knowing X tells you a lot about Y, and the lit row becomes sharply peaked.
A worked example with a test
A disease affects 1 person in 100. A test catches 90% of people who have it, but also wrongly flags 5% of healthy people. You test positive. How likely is it that you have the disease?
- Imagine 10,000 people: 100 have it, 9,900 do not
- True positives: 90% of 100 = 90
- False positives: 5% of 9,900 = 495
- P(disease | positive) = 90 ÷ (90 + 495) ≈ 15%
Most people guess 90%. The real answer is about 15%, because healthy people vastly outnumber sick ones, so even a small false-positive rate produces many false alarms. Drawing the table of counts makes this obvious.
Bayes’ rule
The calculation above is Bayes’ rule: P(A | B) = P(B | A) × P(A) ÷ P(B). It turns “how likely is the evidence if the cause is true” into “how likely is the cause given the evidence”. Spam filters, medical tests and AI models that update their beliefs all use it.
Independent events
Two events are independent when knowing one does not change the chance of the other: P(A | B) = P(A). Coin tosses are independent; drawing cards without putting them back is not.
Mixing up P(A | B) and P(B | A) is one of the most common mistakes in probability, and it appears in courtrooms and news reports.
A spam example
Suppose 20% of emails are spam, the word “prize” appears in 50% of spam and in 2% of normal mail. Out of 1000 emails, 200 are spam with 100 containing “prize”, and 800 are normal with 16 containing it. So P(spam | “prize”) = 100 ÷ 116 ≈ 86%. Real filters combine many words this way.
Glossary
- P(A | B): probability of A given B.
- Prior: belief before seeing evidence.
- Posterior: belief after seeing evidence.
- Independent: one event does not change the other’s chance.
Try these yourself
- Q1. A die shows an even number. Chance it is 6? 1/3
- Q2. Two coins, at least one head. Chance both heads? 1/3
- Q3. P(A and B) = 0.2, P(B) = 0.5: P(A | B) = 0.4
- Q4. Are two fair coin tosses independent? Yes
In short
“Given that” shrinks the world to the cases where the condition is true. Count within that world, and use Bayes’ rule to turn evidence around.
Keep going
Questions people ask
What is conditional probability?
The probability of an event given that another event has happened, written P(A | B).
How do you calculate conditional probability?
P(A | B) = P(A and B) ÷ P(B). With a table of counts, look only at the row or column where B is true.
Why is a positive medical test not always reliable?
When a disease is rare, false positives from the many healthy people can outnumber true positives, as Bayes’ rule shows.