Picture: a test that is good but not perfect: Imagine 1000 people. A rare disease affects only 1% of them — that's just 10 people. A test is 90% accurate: it flags 9 of those 10 sick people, but it also wrongly flags 5% of the 990 healthy people — that's about 50 false alarms!
So of everyone who tests positive (9 + 50 = 59), only 9 are actually sick. A positive result means only about a 15% chance of disease — far less than the test's 90% accuracy suggests.
That surprising flip is exactly what Bayes' theorem computes: it turns P(positive | sick), which the test gives you, into P(sick | positive), which you actually want.
The idea in one sentence: Conditional probability P(A | B) = (probability of A and B) ÷ (probability of B).
To find P(disease | positive), take the one tree branch where you are both diseased and positive, then divide by the total probability of being positive (every path that ends in 'positive').
IB-style question — disease test (read off the tree)
A disease affects 2% of a population. A screening test correctly returns positive for 95% of people who have the disease, and wrongly returns positive for 8% of people who do not have it.
A randomly chosen person tests positive. Find the probability that they actually have the disease.
Step by step
- Set up the tree. First branch: disease D (0.02) or no disease D′ (0.98). Second branch: test result + or −. Multiply along each path to get the joint probabilities.
- Path 'disease AND positive': multiply along that branch.
- Path 'no disease AND positive' (a false positive).
- Total probability of testing positive = sum of every path that ends in '+'.
- Bayes: divide the branch you want by the total. This reverses the conditional.
Final answer
P(disease | positive) ≈ 0.195 (about 19.5%) — much lower than the 95% accuracy, because the disease is rare and false positives outnumber true positives.
Same tree, written as a formula: The tree method is Bayes' theorem. Writing it as a formula just names the pieces. To find P(A | B), you need:
• the prior P(A) — how likely A is before any evidence; • the likelihood P(B | A) — how likely the evidence is when A is true; • and the total probability of the evidence P(B), gathered from every branch (the law of total probability).
IB-style question — use the formula directly
A factory makes light bulbs on two machines. Machine A makes 60% of the bulbs and 3% of its bulbs are faulty. Machine B makes the other 40% and 7% of its bulbs are faulty.
A bulb is chosen at random and found to be faulty (F). Find the probability that it was made by machine B.
Step by step
- Name the pieces. Prior P(B) = 0.40, and likelihood P(F | B) = 0.07. For machine A: P(A) = 0.60, P(F | A) = 0.03.
- Law of total probability — chance any bulb is faulty (both machines).
- Bayes: wanted branch ÷ total. Here the wanted branch is 'machine B and faulty'.
Final answer
P(machine B | faulty) ≈ 0.609. Although B makes only 40% of the bulbs, its higher fault rate means it accounts for most of the faulty ones.
Don't confuse the two directions: P(F | B) = 0.07 is given. P(B | F) ≈ 0.609 is the answer. They are different numbers — swapping them is the single most common Bayes mistake. The whole point of Bayes is that P(A | B) ≠ P(B | A).