Bayes' theorem

Database › Mathematics › Applied mathematics › Probability

PROB-0003TheoremUndergraduate

The probability of a cause given an observation is the likelihood of the observation times the prior probability of the cause, divided by the total probability of the observation.

$$P(A_i|B)=\frac{P(B|A_i)\,P(A_i)}{\sum_j P(B|A_j)\,P(A_j)},\qquad P(A\cap B)=P(A|B)P(B)=P(B|A)P(A)$$

Explanation

The theorem follows from writing the joint probability $P(A\cap B)$ in two ways; the denominator is the law of total probability over a complete set of mutually exclusive causes $A_j$. Independence means $P(A|B)=P(A)$, i.e. $P(A\cap B)=P(A)P(B)$.

When the prior $P(A)$ is small, even an accurate test gives a modest posterior: most positives come from the large unaffected population. In Bayesian inference the same formula updates a probability distribution for a parameter, posterior $\propto$ likelihood $\times$ prior.

Example 1

A disease affects 0.5% of a population. A test detects it in 99% of cases but also gives a positive result for 2% of healthy people. Find the probability that a person who tests positive has the disease.

Solution

$P=\frac{0.99\times0.005}{0.99\times0.005+0.02\times0.995}=\frac{0.00495}{0.02485}\approx0.199$ — only about 20%.

Example 2

A prize is behind one of three doors. You pick door 1; the host, who knows where the prize is and always opens an empty door you did not pick, opens door 3. Should you switch to door 2?

Solution

Let $H$ = host opens 3. $P(H|1)=\frac12$, $P(H|2)=1$, $P(H|3)=0$, priors $\frac13$. Then $P(2|H)=\frac{1\cdot\frac13}{\frac12\cdot\frac13+1\cdot\frac13}=\frac23$: switching doubles the chance.

Related entries