Bayes' theorem

core 10 minprobabilitybayesconditional-probability

Builds on:Common distributions

The idea

Bayes' theorem is the rule for reversing a conditional probability. You usually know how evidence behaves given a hypothesis — test accuracy, model recall, symptom rates. You want the reverse: how probable is the hypothesis given the evidence. They are not the same thing, and the gap between them is set by the prior:

P(H∣E)=P(E∣H) P(H)P(E),P(E)=P(E∣H)P(H)+P(E∣¬H)P(¬H)P(H \mid E) = \frac{P(E \mid H)\,P(H)}{P(E)}, \qquad P(E) = P(E \mid H)P(H) + P(E \mid \neg H)P(\neg H)

Read it as: posterior ∝\propto likelihood ×\times prior. The denominator is just the total probability of seeing the evidence at all, summed over both worlds.

The equivalent odds form is often faster mental math and chains cleanly:

P(H∣E)P(¬H∣E)⏟posterior odds=P(H)P(¬H)⏟prior odds×P(E∣H)P(E∣¬H)⏟likelihood ratio.\begin{aligned} \underbrace{\frac{P(H \mid E)}{P(\neg H \mid E)}}_{\text{posterior odds}} &= \underbrace{\frac{P(H)}{P(\neg H)}}_{\text{prior odds}} \\ &\quad\times \underbrace{\frac{P(E \mid H)}{P(E \mid \neg H)}}_{\text{likelihood ratio}}. \end{aligned}

Each independent piece of evidence multiplies the odds by its likelihood ratio. A signal with LR = 10 is "worth one order of magnitude of odds" no matter what the prior is.

Why interviews love this: the base rate fallacy. When the hypothesis is rare (fraud, disease, churned-whale accounts), even a strong likelihood ratio leaves the posterior small, because the enormous negative class manufactures false positives faster than the tiny positive class produces true ones. Every "the test is 95% accurate, so you are 95% likely sick" claim is this error.

Worked example

Condition prevalence 1%. Test sensitivity 95% (P(+∣sick)P(+ \mid \text{sick})), specificity 90% (so false positive rate 10%). Take 10,000 people:

Sick (100)Healthy (9,900)
Test positive95990
Test negative58,910

Positives total 95+990=108595 + 990 = 1085, of which only 95 are real:

P(sick∣+)=951085≈8.8%P(\text{sick} \mid +) = \frac{95}{1085} \approx 8.8\%

Same answer via odds: prior odds 1:991{:}99, likelihood ratio 0.95/0.10=9.50.95 / 0.10 = 9.5, posterior odds 9.5:99≈0.0969.5{:}99 \approx 0.096, probability 0.096/1.096≈8.8%0.096 / 1.096 \approx 8.8\%.

The population table is the interview-safe method: pick a round number of people, fill in the four cells, and read the answer off the positive row. It is nearly impossible to get wrong under pressure, unlike formula juggling.

Cheat sheet

TermAlso calledFormula
Sensitivityrecall, TPRP(+∣H)P(+ \mid H)
SpecificityTNRP(−∣¬H)P(- \mid \neg H)
FPRfall-out1−specificity1 - \text{specificity}
P(H∣+)P(H \mid +)precision, PPVwhat Bayes computes

Gotchas: