Bayes' Theorem: Updating A Probability When New Evidence Arrives
A disease affects 1 person in 100, a screening test is 95% accurate, and your test comes back positive.
Almost everyone guesses you are now very likely to have the disease, but the real answer is about 16%.
Our intuition fails because we know the wrong conditional: a test report gives $P(\text{positive} \mid \text{disease})$, but we want $P(\text{disease} \mid \text{positive})$.
Bayes' theorem is the rule that flips a conditional probability from the one you know to the one you need.
Deriving Bayes From Conditional Probability
You already have everything needed from the conditional probability formula and the multiplication rule in 4.11.
Conditional probability: $P(A \mid B) = \dfrac{P(A \cap B)}{P(B)}$.
The multiplication rule the other way round gives the top: $P(A \cap B) = P(A)\,P(B \mid A)$.
Substitute it in: $P(A \mid B) = \dfrac{P(A)\,P(B \mid A)}{P(B)}$.
Finally expand $P(B)$ as the two ways $B$ can occur, through $A$ or through $A'$. $$P(A \mid B) = \frac{P(A)\,P(B \mid A)}{P(A)\,P(B \mid A) + P(A')\,P(B \mid A')}$$
Note
Both this two-event form and the three-event form below are given in the formula booklet under Topic 4 (AHL).
So the exam skill is reading the probabilities out of the wording correctly, not memorising the formula.
The Denominator Is Just Total Probability
The scary-looking denominator is only the overall chance of the evidence $B$, found by adding up every path that leads to it.
On a tree diagram it is the sum of the branch products that end in $B$: $P(A)\,P(B \mid A)$ through $A$, plus $P(A')\,P(B \mid A')$ through $A'$.
Bayes' theorem then asks what fraction of that total came through the branch you care about.
Example question
A disease is present in 1% of a population. A test gives a positive result for 95% of people who have the disease, and also for 5% of people who do not. A randomly chosen person tests positive. Find the probability that they actually have the disease.
Solution
Let $D$ be "has the disease" and $+$ be "tests positive", so $P(D) = 0.01$, $P(+ \mid D) = 0.95$, $P(+ \mid D') = 0.05$.
Only about 16% despite a positive test, because the disease is so rare that most positives come from the large healthy group.
Extending To Three Events
Often the evidence can arise from more than two causes.
If the causes $B_{1}, B_{2}, B_{3}$ are mutually exclusive and cover every possibility, Bayes' theorem extends by listing every branch in the denominator.
The three-event version is printed in the formula booklet, so identify the partition of causes first, then fill it in.
The numerator is the single branch you are asking about; the denominator is the sum of all the branches.
The syllabus caps this at a maximum of three events, so you never need more branches than that.
Example question
A factory makes items on three machines. Machine A makes 50% of items, B makes 30%, and C makes 20%. The proportion defective is 2% for A, 3% for B, and 5% for C. An item is found to be defective. Find the probability it was made by machine C.
Solution
Let $D$ be "defective", with priors $P(A)=0.5$, $P(B)=0.3$, $P(C)=0.2$ and $P(D \mid A)=0.02$, $P(D \mid B)=0.03$, $P(D \mid C)=0.05$.
Total probability of a defective: $$P(D) = 0.5(0.02) + 0.3(0.03) + 0.2(0.05) = 0.029$$