Mathematics · Simulator 049
Start with a belief, then update it with evidence. In test mode, see why a positive result for a rare disease often still means you're probably healthy. In coin mode, flip a possibly biased coin and watch the probability distribution for its bias sharpen with each flip.
Bayes' theorem turns a prior belief into a posterior after seeing evidence E:
P(H | E) = P(E | H) · P(H) / P(E)
Medical test. With prevalence p, sensitivity (true positive rate) s and specificity (true negative rate) c:
P(disease | +) = s·p / (s·p + (1 − c)(1 − p))
The icon grid shows 1000 people, so you can count the true and false positives directly. When the disease is rare, false positives from the large healthy group can outnumber true positives.
Coin bias. The prior for the probability of heads θ is a Beta(α, β) distribution. After h heads and t tails, the posterior is Beta(α + h, β + t) (a conjugate update). Its mean (α + h)/(α + β + h + t) moves towards the observed frequency, and its spread shrinks as data accumulate.
Assumes the test result or flips are independent given the true state, and that the stated rates are exact.
A test has 90% sensitivity and 90% specificity. For what prevalence does a positive result mean exactly a 50% chance of disease?
Set s·p = (1 − c)(1 − p): 0.9p = 0.1(1 − p), so p = 0.1. At 10% prevalence, true and false positives are equally common. Below that, most positives are false.