Bayes' Theorem
Updates a probability given new evidence.
Formula
Variables
Example
A test 99% accurate on a 1%-prevalence disease still yields many false positives — Bayes shows a positive means only ~50% chance of illness.
How it works
Bayes' Theorem lets you reverse a conditional probability: if you know how likely the evidence is under each possible cause, it tells you how to update your belief in one cause after seeing that evidence. It works because the joint probability of "A and B" can be written in two ways: P(A and B) = P(B|A)P(A) = P(A|B)P(B), so rearranging gives the update rule. In practice, it combines your prior belief P(A) with how well the new evidence fits A compared with all other possibilities.
When to use it
Use Bayes' Theorem when you want the probability of a hidden cause after observing data, such as in medical testing, spam filtering, fault diagnosis, or risk assessment. It is especially useful when the reverse probability is not directly given but the forward probabilities are known.
Worked example, step by step
Suppose a factory has two machines making bolts: - Machine A makes 70% of bolts: P(A) = 0.70 - Machine B makes 30% of bolts: P(B) = 0.30 - 2% of bolts from A are defective: P(D|A) = 0.02 - 5% of bolts from B are defective: P(D|B) = 0.05 We want the probability that a defective bolt came from Machine B: P(B|D). Step 1: Find the overall probability of a defect. P(D) = P(D|A)P(A) + P(D|B)P(B) P(D) = (0.02)(0.70) + (0.05)(0.30) P(D) = 0.014 + 0.015 = 0.029 Step 2: Apply Bayes' Theorem. P(B|D) = [P(D|B)P(B)] / P(D) P(B|D) = (0.05 × 0.30) / 0.029 P(B|D) = 0.015 / 0.029 P(B|D) ≈ 0.517 Final answer: The probability a defective bolt came from Machine B is about 51.7%.
Common mistakes to avoid
- Confusing P(A|B) with P(B|A) and using the probabilities in the wrong direction
- Forgetting to calculate P(B) as the total evidence from all possible sources
- Treating the prior probability as irrelevant instead of combining it with the evidence
Did You Know?
Bayes' theorem powers spam filters, medical diagnostics, and modern AI — yet it was published only after its author's death.
Share this formula
More in Statistics & Probability
View allArithmetic Mean
BasicThe average of a data set.
Median
BasicThe middle value separating the higher and lower halves.
Variance
IntermediateAverage squared deviation from the mean.
Standard Deviation
IntermediateSquare root of the variance; typical spread.
Z-Score
IntermediateNumber of standard deviations a value is from the mean.
Combinations
IntermediateNumber of ways to choose r items from n (order irrelevant).