Probability

Bayesian Inference

A disease test can be accurate and still produce many false positives when the disease is rare. Adjust prevalence, sensitivity, and specificity to see the posterior probability update.

7 minLevel 2/3The interactive stage stays ad-free.
Prior1%Sensitivity90%Specificity90%P(disease | positive)8.3%
True positive: 9 False negative: 1 False positive: 99 True negative: 891

Even with 90% sensitivity and 90% specificity, a positive test at 1% prevalence means only about 8% of positive people actually have the disease. False positives come from the much larger healthy group.

What you are seeing

1

The prior is the chance of having the disease before testing.

2

Sensitivity is the true-positive rate; specificity is the true-negative rate. Their complements produce false negatives and false positives.

3

Bayes’ theorem combines the prior with the evidence to produce the posterior probability.

Why it matters

Bayesian reasoning is essential in medical testing, spam filtering, diagnostics, and decision-making under uncertainty. It exposes the base-rate fallacy.

Complexity & details

A single update costs O(1). A 1,000-person grid costs O(population) to render.

Frequently asked questions

Why can a positive test still be wrong?+

When the disease is rare, most positive results come from the much larger healthy population, even if the false-positive rate is small.

What is the difference between prior and posterior?+

The prior is the belief before seeing evidence. The posterior is the updated belief after combining the prior with the likelihood of the evidence.