The conditional probability formula
P(A | B) = P(A ∩ B) ÷ P(B)
Example: P(A ∩ B) = 15%, P(B) = 40%
P(A | B) = 15% ÷ 40% = 37.5%
In words: out of all the times B happens, what fraction of those times does A also happen? P(B) must be greater than 0 — if B can never occur, the condition "given B" is meaningless. P(A ∩ B) can never exceed P(B) either, since the times both A and B happen are necessarily a subset of the times B happens alone.
P(A|B) is not the same as P(B|A)
This is the single most common mistake with conditional probability — treating "probability of A given B" as interchangeable with "probability of B given A." They usually are not equal. Building a table from raw counts makes the difference concrete:
| B | Not B | |
|---|---|---|
| A | 10 | 10 |
| Not A | 40 | 40 |
P(A | B) = 10 ÷ (10 + 40) = 10 ÷ 50 = 20%
P(B | A) = 10 ÷ (10 + 10) = 10 ÷ 20 = 50%
Same 100 data points, same 10 people in both categories — but a 20% chance versus a 50% chance depending on which direction you ask the question. Confusing the two is common enough in legal and medical contexts that it has a name: the prosecutor's fallacy.
Bayes' theorem: working backwards from evidence
Bayes' theorem answers a specific, very common question: given a positive test result, what's the real probability of having the condition being tested for? It requires three things — how common the condition is (the prior), how often the test is right when the condition is present (sensitivity), and how often it falsely triggers when the condition is absent (the false-positive rate).
P(A | B) = [P(B | A) × P(A)] ÷ P(B)
where P(B) = P(B|A)×P(A) + P(B|not A)×P(not A)
The classic example: a rare disease, an accurate test
Suppose a disease affects 1% of the population. A test for it is 99% accurate for people who have the disease (sensitivity), but also gives a false positive 5% of the time for people who don't. You test positive. What is the actual probability you have the disease?
P(Positive) = (99% × 1%) + (5% × 99%) = 0.99% + 4.95% = 5.94%
P(Disease | Positive) = 0.99% ÷ 5.94% = 16.67%
Despite a "99% accurate" test, a positive result only means a 16.67% chance of actually having the disease — because the disease is rare, the much larger healthy population generates more false positives (4.95%) in absolute terms than the small sick population generates true positives (0.99%). This is the single most important intuition in Bayesian reasoning: the rarer the condition, the more a positive result is dominated by false alarms, no matter how accurate the test sounds.
Bayes’ theorem in its most common disguise
Bayes’ theorem is commonly used in diagnostic testing, where the same probabilities are given different names. A test’s sensitivity is P(positive | has it), and its specificity is P(negative | doesn’t). What a positive result often prompts us to ask is the reverse: given a positive result, how likely is it to be right? That is the positive predictive value, and Bayes’ theorem connects the two.
PPV = P(has it | positive) = [sensitivity × prevalence] ÷ P(positive)
The diagnostic test tab takes those three numbers and calculates the positive and negative predictive values.
Why a 99% accurate test can be wrong most of the time
Take a condition affecting 1 in 100 people, and a test that catches 99% of cases and correctly clears 95% of healthy people. You test positive. Most people guess the result is about 95–99% likely to be right.
It is 16.7%. Out of 10,000 people tested:
- 100 have the condition; 99 of them test positive.
- 9,900 do not; 5% of them — 495 people — test positive anyway.
- So 594 positives, of which only 99 are correct: 99 ÷ 594 = 16.7%.
The false positives swamp the true ones, because there are so many more healthy people to draw them from. This is the base-rate fallacy: the prevalence matters as much as the accuracy, and ignoring it produces an answer that is wrong by a factor of five.
Counting people rather than multiplying percentages is what makes it obvious, which is why the calculator shows the breakdown out of 10,000 alongside the figure.
See probability in action with a simple game. The Die & Card Probability Game combines die rolls and card draws so you can explore probabilities across a set of equally likely outcomes.
Frequently asked questions
What is the positive predictive value?
The positive predictive value (PPV) is the probability that a positive result is correct: P(has it | positive). It is not the same as sensitivity, which runs the other way — P(positive | has it) — and it depends on how common the condition is, not only on how good the test is. Use the diagnostic test tab to calculate PPV from prevalence, sensitivity, and specificity.
Why does prevalence change the answer so much?
Because false positives are drawn from everyone who does not have the condition, and when it is rare that group is enormous. A 5% false-positive rate applied to 9,900 people without the condition produces 495 wrong positives — far more than the 99 right ones from the 100 who are affected. This is why prevalence is essential when interpreting a positive test result. Try the diagnostic test tab to see how prevalence, sensitivity, and specificity affect predictive values.
What is conditional probability?
Conditional probability is the chance of an event happening given that another event is already known to have happened. It's written P(A|B), read "probability of A given B," and calculated as P(A ∩ B) ÷ P(B).
How do you find conditional probability from a table?
Find the count where both events occur, and divide it by the total count for the "given" event's column or row. For P(A|B), divide the A-and-B count by the total count of B (both A-and-B plus not-A-and-B).
What is Bayes' theorem used for?
Bayes' theorem reverses a conditional probability — it converts "probability of a positive test given the disease" into the more useful "probability of the disease given a positive test." It's used throughout medical testing, spam filtering, forensic evidence, and machine learning.
Why isn't a "99% accurate" test 99% reliable?
"99% accurate" usually describes sensitivity — how often the test is right when the condition is present — not the chance you have the condition given a positive result. For rare conditions, false positives from the much larger healthy population can outnumber true positives, pulling the real probability far below 99%, as the disease example above shows.
Can P(A|B) be greater than P(A)?
Yes, whenever A and B are positively associated — knowing B happened makes A more likely than it was on its own. If they're negatively associated, P(A|B) is lower than P(A). If A and B are independent, P(A|B) equals P(A) exactly, since knowing about B tells you nothing about A.