← All concepts

Probabilistic Reasoning

Bayes' Theorem

Updating a prior belief with evidence to get a posterior: P(H|E) = P(E|H)·P(H) / P(E).

A screening test on 1,000 people. Each icon is 5 people: green icons are sick, grey are healthy. Icons inside the orange circle tested positive. Move the sliders and watch who ends up inside it.

Medical test Venn diagram with peoplePerson icons inside a rectangle of 1,000 people; green icons are sick, grey are healthy; icons inside the orange circle tested positive.1,000 people screened · 1 icon = 5 peopleHas diseaseTests positive
Sick person Healthy person

Sick and positive

45 people

Healthy but positive

95 people

All positives

140 people

P(sick | positive)

32.1%

Inside the orange circle there are 140 people, but only 45 of them are sick: 45 ÷ 140 ≈ 32.1%.

Why it works

Call “has the disease” A and “tests positive” B. The overlap A ∩ B can be measured from either circle:

P(A ∩ B) = P(B|A) · P(A) = P(A|B) · P(B)

Set the two equal and divide by P(B):

P(A|B) = P(B|A) · P(A) / P(B)

The denominator splits B into the part inside A and the part outside it:

P(B) = P(B|A)·P(A) + P(B|¬A)·P(¬A)

Once you know you tested positive, the orange circle becomes your whole world. P(sick | positive) is the share of that circle taken up by green icons.

Things to try

  • With the defaults (5% prevalence, 90% sensitivity, 10% false positives), only about 32% of positives are actually sick. The disease is rare, so false alarms from the large healthy group outnumber real cases.
  • Raise prevalence to 30%, or drop false positives to 1%, and the green icons take over the orange circle.
  • Check it by hand: (0.9 × 0.05) / (0.9 × 0.05 + 0.1 × 0.95) = 0.045 / 0.14 ≈ 0.321.

Circle areas are drawn to scale. Icons are rounded to the nearest 5 people, so very small groups may show no icon; the counts in the cards are exact.