Bayes' theorem
Bayes' theorem finds the probability of a cause after seeing the result: P(Eᵢ|A) = P(Eᵢ)P(A|Eᵢ)/P(A), with P(A) from total probability.
Statement and proof
Let E₁, E₂, ..., Eₙ be a partition of S, and A any event with P(A) ≠ 0.
- 1Definition: P(Eᵢ|A) = P(A ∩ Eᵢ)/P(A).
- 2Multiplication theorem: P(A ∩ Eᵢ) = P(Eᵢ) P(A|Eᵢ).
- 3Total probability: P(A) = P(E₁)P(A|E₁) + P(E₂)P(A|E₂) + ... + P(Eₙ)P(A|Eₙ).
- 4★So, P(Eᵢ|A) = P(Eᵢ)P(A|Eᵢ) / Σ P(Eⱼ)P(A|Eⱼ), summed over j = 1 to n.
★ key step
Method, and how to draw the tree
- Name the causes E₁, E₂, ... (machines, bags, groups) and the result A.
- Draw a tree: the first branches carry the priors P(Eᵢ); the second branches carry P(A|Eᵢ).
- Multiply along each branch to get P(Eᵢ)P(A|Eᵢ).
- Add all the branches ending in A to get P(A), the denominator.
- Divide the branch you want by P(A). That is the posterior P(Eᵢ|A).
Example 1: which machine?
Machines X, Y and Z make 50%, 30% and 20% of the bolts, with 2%, 3% and 4% defective. A bolt is found defective. Find the probability that it came from each machine.
- By total probability, P(D) = 0.010 + 0.009 + 0.008 = 0.027.
- P(X|D) = 0.010/0.027 = 10/27
- P(Y|D) = 0.009/0.027 = 9/27 = 1/3
- P(Z|D) = 0.008/0.027 = 8/27
- Check: 10/27 + 9/27 + 8/27 = 1
P(X|D) = 10/27, P(Y|D) = 1/3, P(Z|D) = 8/27.
Example 2: a screening test
A disease affects 1% of a town. A test is positive for 95% of people who have it, and also for 5% of people who do not (example values). A person tests positive. Find the probability that the person has the disease.
- E₁: has the disease, P(E₁) = 0.01. E₂: does not, P(E₂) = 0.99.
- A: tests positive. P(A|E₁) = 0.95 and P(A|E₂) = 0.05.
- Numerator: 0.01 × 0.95 = 0.0095
- Denominator: 0.0095 + 0.99 × 0.05 = 0.0095 + 0.0495 = 0.059
- P(E₁|A) = 0.0095/0.059 = 95/590 = 19/118
19/118, about 0.16 (rounded to 2 decimal places). Most positive results here are false alarms, because the disease is rare.
Example 3: which bag?
Bag I has 4 green and 2 white marbles; Bag II has 3 green and 5 white. A coin decides the bag, and a green marble is drawn. Find the probability that it came from Bag I.
- P(I) = P(II) = 1/2; P(G|I) = 2/3 and P(G|II) = 3/8
- P(G) = 1/3 + 3/16 = 25/48, by total probability
- P(I|G) = (1/2 × 2/3)/(25/48) = (1/3)/(25/48)
- = (16/48) ÷ (25/48) = 16/25
P(Bag I | green) = 16/25.
P(A|Eᵢ) vs P(Eᵢ|A)
Mixing these up is the most common error: in Example 2 they are 0.95 and about 0.16.
Doctors use this reasoning when a screening test for TB or diabetes is positive: the chance of really having the disease depends on how common it is, not only on how accurate the test is. That is why a second test is often advised.
1 marks: “In Bayes' theorem, what is P(Eᵢ|A) called?” The posterior probability of Eᵢ.
3 marks: “In a college, 70% of students are day scholars and 30% are hostellers. 20% of day scholars and 60% of hostellers own a bicycle. A student with a bicycle is chosen. Find the probability that the student is a hosteller.” P(B) = 0.7 × 0.2 + 0.3 × 0.6 = 0.14 + 0.18 = 0.32. P(H|B) = 0.18/0.32 = 9/16.
5 marks: “In a school, 30% of Class 12 students take science, 45% commerce and 25% humanities. The chances of scoring above 90% are 0.2, 0.1 and 0.12. A student scored above 90%. Find the probability that the student is from science.” P(A) = 0.3 × 0.2 + 0.45 × 0.1 + 0.25 × 0.12 = 0.06 + 0.045 + 0.03 = 0.135. P(Science|A) = 0.06/0.135 = 4/9.
Bayes = my branch ÷ all the branches.