Conditional probability · Definition
Bayes' theorem
Before you start you need to know
It takes us from what we observe back to what caused it: updating an initial belief with new evidence.
Definition
Bayes' theorem inverts a conditional probability: it gives the probability \(P(B_j\mid A)\) of a cause \(B_j\) given an observed effect \(A\), from the probability of the effect given that cause.
Writing \(P(A\cap B)\) in two ways, \(P(B\mid A)P(A)=P(A\mid B)P(B)\), and solving gives \(P(B\mid A)=P(A\mid B)P(B)/P(A)\). When \(B_1,\dots,B_n\) is a partition, the denominator \(P(A)\) is computed with total probability, which yields the full formula. \(P(B_j)\) is called the prior, \(P(A\mid B_j)\) the likelihood and \(P(B_j\mid A)\) the posterior probability.
Guiding example: a disease affects 1 % of the population; the test is positive for 99 % of the sick and 5 % of the healthy. A positive result has probability \(\dfrac{0.01\cdot0.99}{0.01\cdot0.99+0.99\cdot0.05}=\tfrac16\) of belonging to a sick person. Although the test looks very reliable, the disease is so rare that false positives among the healthy outnumber true positives.
So the posterior depends both on the evidence and on the initial proportion of each case. With a coin that is either fair or two-headed, each consecutive head raises the suspicion of the trick coin: after three heads it goes from 1/2 to 8/9. This is the basis of Bayesian inference.
The most common mistake is confusing \(P(A\mid B)\) with \(P(B\mid A)\), or ignoring the prior (the «base rate fallacy»). If \(P(A\mid B_i)\) is the same for every case, observing \(A\) changes nothing: the posterior equals the prior.
Think about it
If the test were perfect (no false positives), what would be the probability of being sick after a positive?
It would be 1: the healthy term in the denominator vanishes and numerator and denominator coincide.
Why can a test with 99 % sensitivity give an inconclusive positive?
Because if the disease is rare, false positives from the huge healthy population can outnumber the true positives.
Exercises 10
- If \(P(B)=0.3\), \(P(A\mid B)=0.8\) and \(P(A)=0.4\), what is \(P(B\mid A)\)?
- A coin is either fair or two-headed, with equal probability. It is tossed once and shows heads. What is the probability that it is the two-headed coin?
- Which is the correct statement of Bayes' theorem?
- Urn A has 3 red and 2 blue balls; urn B has 1 red and 4 blue. A fair coin picks an urn and a red ball comes out. What is the probability it came from A?
- Three machines make 50 %, 30 % and 20 % of the parts, with 1 %, 2 % and 5 % defective. A part is found defective. What is the probability it came from machine 1?
- There are three cards: one red on both sides, one red and blue, one blue on both sides. A card is drawn at random and its visible face is red. What is the probability the other face is red?
- A coin is fair or two-headed with equal probability. It is tossed three times and shows three heads. What is the probability it is the two-headed coin?
- A disease affects 1 %. The test is positive for 99 % of the sick and 5 % of the healthy. If you test positive, what is the probability you are sick?
- If \(0<P(B)<1\) and \(P(A\mid B)=P(A\mid B^c)>0\), what follows for \(P(B\mid A)\)?
- A disease affects 1 in 1000. The test is positive for 99 % of the sick and 1 % of the healthy. If you test positive, what is roughly the probability you are sick?
References
- Joseph K. Blitzstein, Jessica Hwang, Introduction to Probability, 2nd edition, CRC Press, 2019. §2.3
- Sheldon Ross, A First Course in Probability, 10th edition, Pearson, 2019. §3.3
- Larry Wasserman, All of Statistics, 1st edition, Springer, 2004. §1.4