Category: Probability Level: 301
P(D | +) = P(D)P(+ | D) / (P(D)P(+ | D) + P(H)P(+ | H))
Draw all possibilities as a square of area 1. Split it into sick and healthy, then split each part by test result. The answer is one slice of positive area over all of it.
The whole square has area 1: every person, every outcome.
total area = 1
A thin strip on the left stands for the 1% who are sick. It is drawn wider than true scale so you can see it at all.
P(D) = 0.01; P(H) = 0.99
In the sick strip, 90% of the height tests positive. In the healthy part, only 9% does. Positive area is shaded.
P(+ | D) = 0.90; P(+ | H) = 0.09
Each area is a width times a height. The purple area is about ten times the red one, even though it looks thin.
0.01 × 0.90 = 0.0090, 0.99 × 0.09 = 0.0891
Given a positive test, you are somewhere in the shaded area. The red part is your chance of being sick.
0.0090 / (0.0090 + 0.0891) ≈ 0.092
cd svg-generator python3 -m svgmath render bayes-area-square --out /tmp/bayes-area-square
Source: svgmath/diagrams/probability.py