You know how often a symptom appears in sick people. You want to know how likely
someone is sick given that they have the symptom. Those are different questions,
and Bayes' theorem is the machinery for turning one into the other.
The reason the answer surprises people is that it depends on a third number they
tend to ignore: how common the disease is in the first place. If almost nobody has
the disease, then even a good test produces far more false alarms than true ones —
simply because there are so many more healthy people to generate false alarms
from.
That is the entire content of the theorem. Reversing a conditional probability
requires knowing the base rate, and ignoring the base rate is the most expensive
mistake in applied probability.
The statement
For events A and B with P(B)>0:
P(A∣B)=P(B)P(B∣A)P(A)
Expanding the denominator with the law of total probability gives the form you
will actually compute with:
The multiplication rule can be written two ways, because A∩B and
B∩A are the same event:
P(A∩B)=P(A∣B)P(B)P(A∩B)=P(B∣A)P(A)
Set the right-hand sides equal:
P(A∣B)P(B)=P(B∣A)P(A)
Divide by P(B), which is legitimate since P(B)>0:
P(A∣B)=P(B)P(B∣A)P(A)
That is the whole proof. Bayes' theorem is not a deep new assumption — it is the
symmetry of the joint probability, rearranged. The depth is in how it is used,
not in what it says.
Why the base rate dominates
Write out the numerator and denominator as counts rather than probabilities. In a
population of N people:
true positives: N×P(A)×P(B∣A)
false positives: N×P(Ac)×P(B∣Ac)
The posterior is true positives divided by all positives. When P(A) is tiny,
P(Ac)≈1, so the false-positive count is governed almost entirely by
the false-positive rate applied to nearly the whole population. A small rate
times a large group easily exceeds a large rate times a small group.
Rare condition, good test. The 995 false positives (light) swamp the 99 true positives (dark), so a positive result is still probably a false alarm.
Solved problem 1 · The medical test, in probabilities
A screening test detects 99% of true cases (sensitivity) and is 95% specific. The
disease affects 1 in 200 people. A patient tests positive. What is the probability
they have the disease?
Step 1 — translate the words into probabilities
Let D = has the disease, + = tests positive.
P(D)=2001=0.005(prevalence, the prior)P(+∣D)=0.99(sensitivity)P(−∣Dc)=0.95(specificity)
Step 2 — derive the two quantities not stated directly
P(D∣+)≈0.0905, about 9%. Despite a test that is right 99% of
the time on sick people, a positive result leaves the patient more than 90% likely
to be healthy.
The odds form
For repeated updates, the odds form is far more convenient. Divide Bayes' theorem
for A by Bayes' theorem for Ac — the P(B) cancels:
posterior oddsP(Ac∣B)P(A∣B)=likelihood ratioP(B∣Ac)P(B∣A)×prior oddsP(Ac)P(A)Deriving the odds form and why the constant vanishesAdvanced
Write Bayes' theorem for both A and its complement:
P(A∣B)=P(B)P(B∣A)P(A),P(Ac∣B)=P(B)P(B∣Ac)P(Ac)
Divide the first by the second. The P(B) in each denominator cancels:
P(Ac∣B)P(A∣B)=P(B∣Ac)P(Ac)P(B∣A)P(A)
which is the stated result. The practical gain is that P(B) — usually the
most tedious part — never has to be computed. Recover the probability at the end
with
P(A∣B)=1+oddsodds
Taking logarithms makes it additive, which is exactly the structure of logistic
regression: log-posterior-odds equals log-prior-odds plus a sum of log-likelihood
ratios, one per feature. That connection is not a coincidence — naive Bayes and
logistic regression are the same linear form fitted differently.
Solved problem 2 · The same problem in odds
Redo Solved problem 1 using the odds form.
Step 1 — prior odds
P(Dc)P(D)=0.9950.005=1991
Odds of 1 to 199 against.
Step 2 — likelihood ratio
P(+∣Dc)P(+∣D)=0.050.99=19.8
A positive result is 19.8 times more likely in a sick person. This is the
diagnostic value of the test, in one number.
Step 3 — multiply
posterior odds=19.8×1991=19919.8≈0.09950
Step 4 — convert back to a probability
P(D∣+)=1+0.099500.09950≈0.0905✓
Answer
Same ≈0.0905, with less arithmetic — and the evidence term never appeared.
Solved problem 3 · A second independent test
The patient from Solved problem 1 takes a second, independent test with the same
characteristics. It is also positive. Now what?
Step 1 — the posterior becomes the new prior
After one positive, the odds were 19.8/199≈0.09950. Bayesian updating is
sequential: yesterday's posterior is today's prior.
Step 2 — multiply by the likelihood ratio again
Conditional independence of the two tests given disease status means the
likelihood ratio applies unchanged:
posterior odds=19.8×0.09950≈1.9701
Step 3 — convert
P(D∣+,+)=1+1.97011.9701≈0.663
Answer
About 66% — up from 9%. Two independent positives move the conclusion from
"probably fine" to "probably ill", which is precisely why confirmatory testing
exists.
Common misreadings
Where this reappears
Bayes' theorem is not one topic among many; it is load-bearing across the whole
curriculum:
Naive Bayes classifiers apply it directly, with a conditional-independence
assumption across features.
Bayesian inference replaces events with parameters:
p(θ∣data)∝p(data∣θ)p(θ).
MAP estimation maximises that posterior; maximum likelihood is the
special case of a flat prior.
Bayesian networks are factorised joint distributions queried with Bayes'
rule and the law of total probability.
Variational autoencoders approximate an intractable posterior p(z∣x),
which is where the ELBO comes from.
Precision in classification is a posterior:
P(positive class∣predicted positive) — which is why
precision collapses on imbalanced data exactly as the medical test does.
Exercise 1
A factory has two machines. Machine A makes 70% of items with a 1% defect rate;
machine B makes 30% with a 4% defect rate. An item is found defective. What is the
probability it came from machine B?
Machine B makes under a third of the output but produces nearly two thirds of the
defects. Useful check: the two posteriors must sum to 1, and
0.007/0.019≈0.368, with 0.368+0.632=1✓
Exercise 2
A spam filter flags 95% of spam and wrongly flags 2% of legitimate mail. 30% of
incoming mail is spam. An email is flagged. What is the probability it is spam?
Contrast with the medical case: here the base rate is 30% rather than 0.5%, so the
posterior is high. Same theorem, utterly different conclusion — the prior is doing
the work.
Exercise 3
A test has sensitivity 0.90 and specificity 0.90. For which prevalence does a
positive result give exactly P(D∣+)=0.5?
Show solutionHide solution
Use the odds form. The likelihood ratio is
1−0.900.90=0.100.90=9
A posterior probability of 0.5 means posterior odds of exactly 1. So
1=9×prior odds⟹prior odds=91
Converting odds to a probability:
P(D)=1+1/91/9=101=0.10
At 10% prevalence a positive result is a coin flip. Below that it is more likely a
false alarm than a true one — a useful rule of thumb: a positive is only
"probably right" when prevalence exceeds the reciprocal of the likelihood ratio.
Next: Random Variables, where we stop
talking about events and start attaching numbers to outcomes — the step that makes
expectation and variance possible.