See the math behind testing & treatment
Watch a population flow through a test and a treatment into outcomes. Change any input and every view updates live — from false positives and predictive value to who is actually helped or harmed. No verdicts, just the numbers.
Key results
Teaching example1,000 people · 1% prevalence · 90% sensitivity · 90% specificity · NNT 10, NNH 20.
Of 108 positive results, 9 are true positives — a positive result means disease 8.3% of the time. 1 case is missed.
- Positive predictive value
- 8.3%
- Negative predictive value
- 99.9%
- False positives
- 99
- Missed cases
- 1
- Helped · harmed
- 1 · 5
Every view below updates as you change an input. Whole people are rounded for the diagrams; percentages use exact expected values. Read the assumptions.
About this tool — what it is and how to read it
Screening and treatment decisions hinge on a few numbers — how common a condition is, how accurate the test is, and how much the treatment helps or harms. Those numbers interact in ways that are easy to misjudge, especially when a condition is rare.
This is a tool to review those numbers. Set a population, a disease prevalence, a test's sensitivity and specificity, and a treatment's benefit and harm, then watch a single cohort flow from population → test → treatment → outcome — true and false positives, predictive value, and the expected numbers helped and harmed (which can overlap). Plug in your own figures, or use the cited examples next to each slider.
Key terms
- Prevalence (pre-test probability)
- How common the condition is in the group being tested. The starting point for everything downstream.
- Sensitivity
- Of people who have the condition, the share the test correctly flags positive.
- Specificity
- Of people who do not have it, the share the test correctly clears.
- PPV / NPV
- Given a positive (or negative) result, the chance it is right. Unlike sensitivity/specificity, these depend heavily on prevalence.
- Likelihood ratio (LR)
- How much a result shifts the odds. LR+ for a positive, LR− for a negative — and they do not depend on prevalence.
- NNT / NNH
- Number needed to treat for one person to benefit; number needed to harm for one to be harmed.
- NNS
- Number needed to screen: in a trial, how many people must be offered a screening program to prevent one bad outcome. It is a program-level figure, not a treatment NNT. This tool’s own “screens per modeled benefit” (screened ÷ helped) is an illustration, not a trial NNS.
Population flow
The cascade
A cohort of 1,000 flows left to right: who has the disease, what the test says, who gets treated, and modeled outcomes. Band height = expected people. The outcome partition shows the minimum possible overlap; benefit and harm can occur together.
- Population
- Diseased 10
- Healthy 990
- Test result
- True + 9
- False − 1
- False + 99
- True − 891
- Treatment
- Treated 108
- Not treated 892
- Outcome
- Benefit only 1
- Harm only 5
- Neither 102
- Missed 1
- Cleared 891
What happens to everyone
Rounded illustration with the minimum possible benefit–harm overlap. One square per person.
Compare two scenarios
Save a baseline, then change any input. Both columns use 1,000 screened so population size cannot disguise a change in rates. The baseline starts as the scenario you opened.
| Measure | Saved | Current | Difference |
|---|---|---|---|
| Prevalence | 1.00% | 1.00% | 0.00 pp |
| Sensitivity | 90.00% | 90.00% | 0.00 pp |
| Specificity | 90.00% | 90.00% | 0.00 pp |
| Positive predictive value | 8.33% | 8.33% | 0.00 pp |
| True positives / 1,000 | 9.00 | 9.00 | 0.00 |
| False positives / 1,000 | 99.00 | 99.00 | 0.00 |
| Missed disease / 1,000 | 1.00 | 1.00 | 0.00 |
| Expected benefit / 1,000 | 0.90 | 0.90 | 0.00 |
| Expected harm / 1,000 | 5.40 | 5.40 | 0.00 |
Saved treatment: NNT 10, NNH 20, uptake 100%. Current: NNT 10, NNH 20, uptake 100%. Benefit and harm describe different endpoints and may overlap; their difference is not a net clinical benefit. The saved baseline lasts while this page is open and is not included in shared links.
The test
2×2 confusion matrix
Rounded counts for 1,000 people. Probabilities use unrounded expected counts. Sensitivity reads across the disease row; PPV reads down the test-positive column — they look at the table from perpendicular directions.
| Test + | Test − | Total | |
|---|---|---|---|
| Disease + | TP9 | FN1 | 10 |
| Disease − | FP99 | TN891 | 990 |
| Total | 108 | 892 | 1,000 |
- Sensitivity TP ÷ (TP + FN) disease + row →
- Specificity TN ÷ (TN + FP) disease − row →
- PPV TP ÷ (TP + FP) test + column ↓
- NPV TN ÷ (TN + FN) test − column ↓
- LR+ sensitivity ÷ (1 − specificity)
- LR− (1 − sensitivity) ÷ specificity
Probability tree
Split the population by disease, then by test result. Each path multiplies to a joint probability; Bayes just compares the two test-positive leaves.
P(disease | test +) = 0.90% ÷ (0.90% + 9.9%) = 8.3%
How PPV collapses with prevalence
Holding sensitivity and specificity fixed, the value of a positive result depends almost entirely on how common the disease is. The dashed line marks the current prevalence.
The base-rate fallacy: at 1% prevalence, even a 90%/90% test makes a positive result correct only 8% of the time. Accuracy isn't the whole story — the base rate is.
Fagan nomogram
The likelihood ratio is the lever that turns a pre-test probability into a post-test one — and it doesn't depend on prevalence. Line shown for a positive result (LR+).
This is Bayes' theorem, in odds form: prior odds × likelihood ratio = posterior odds. A large LR+ or small LR− can shift the odds strongly; neither is a universal diagnostic threshold. The starting probability still matters.
The treatment
Treatment outcomes
Illustrative treatment model. Use NNT and NNH for the same population, outcome definitions, comparison, and follow-up period. A trial’s number needed to screen is not a treatment NNT.
108 interventions performed — 99 on people who never had the disease and so could not benefit.
Helped and harmed are separate effects that can overlap: within this illustration, between 0.00 and 0.90 expected people could experience both. The tiles, bands and squares use the minimum (0 people), so helped + harmed − both + neither = 108 treated. The inputs do not determine the actual overlap. “Neither” means neither modeled treatment effect, not a prediction of a person’s health.
Per 1,000 screened (expected): about 0.90 helped, 5.40 harmed by treatment, 99.00 false alarms, and 1.00 missed.
Watch the relative-vs-absolute trap: a large “relative risk reduction” can still mean a large NNT when the baseline risk is low. Benefit (NNT) only means something next to its harms — that's why helped and harmed are always shown on the same denominator here.
Repeat testing
Serial testing — the false-alarm pile-up
For someone who remains disease-free, 1 − specificityn gives the chance of at least one false alarm if every round has the same specificity and errors are independent. Dependence can put the result above or below this curve. Hover to preview, click or drag to choose a round, or use the round control below.
At 10 rounds: 65.1% under independence. With the same per-round specificity but unknown dependence, the possible range is 10.0%–>99.99%. Bounds: 1 − specificity to min(1, n × (1 − specificity)).
Reference points (≥1 false positive): Elmore et al., NEJM 1998 — 49% after 10 mammograms · Croswell et al., Ann Fam Med 2009 — ~60% (men) / 49% (women) after 14 multimodal PLCO tests.
Bayesian updating
Bayesian updating: learning a rate from data
Where do numbers like sensitivity or prevalence come from? You start with a prior belief, observe data, and get a posterior. For a rate, this is exact
and runs right here — no simulation: posterior = Beta(α+k, β+n−k).
The posterior mean sits between your prior mean and the observed rate — and more data gives the observations more weight. Additional data need not narrow the interval on every update. That shrinking uncertainty is what the screening sliders quietly assume away by treating each rate as a fixed number.
How to use this calculator
- Set the population — how many people you screen.
- Set the prevalence — the pre-test probability, i.e. how common the condition is in that group. This is the single biggest driver of predictive value.
- Set the test’s sensitivity and specificity — how well it catches the condition and how well it clears the healthy.
- Set treatment uptake and the NNT / NNH — how many test-positives go on to treatment, and how often that treatment helps or harms.
Every view — the cascade, the 2×2 confusion matrix, the Bayes tree, the prevalence→PPV curve, the Fagan nomogram, the serial-testing curve, and the helped / harmed outcomes — recomputes live as you change any input. Use the cited examples next to each control to drop in real-world figures.
A worked example: why a positive test can still be a false alarm
Take 1,000 people, a condition with 1% prevalence, and a test that is 90% sensitive and 90% specific — the values this tool starts with. Of the 1,000, about 10 have the condition and 990 do not. The test correctly flags 9 of the 10 true cases (true positives) but also wrongly flags 99 of the 990 healthy people (false positives). So 108 people get a positive result, yet only 9 actually have the condition — a positive predictive value of about 8%. The result feels alarming, but most positives are false. That gap between a test’s accuracy and what a positive result actually means is the base-rate fallacy, and it is the whole point of this tool.
Frequently asked questions
What is positive predictive value (PPV)?
PPV is the probability that someone who tests positive truly has the condition. Unlike sensitivity and specificity — which are properties of the test — PPV also depends heavily on prevalence: the rarer the condition, the lower the PPV, even for a very accurate test.
Read the full guide →Why can a positive test still mean you probably don’t have the condition?
When a condition is rare, the healthy group is so much larger than the sick group that even a small false-positive rate produces more false positives than true positives. In this calculator’s worked example, a 90% / 90% test at 1% prevalence gives a PPV of only about 8%: of 108 positives, 9 have the condition.
Read the full guide →How do you calculate PPV from sensitivity, specificity, and prevalence?
By Bayes’ theorem: PPV = (sensitivity × prevalence) ÷ [ sensitivity × prevalence + (1 − specificity) × (1 − prevalence) ]. The negative predictive value (NPV) is the mirror image for people who test negative.
Read the full guide →What is a likelihood ratio, and why doesn’t it depend on prevalence?
A likelihood ratio summarizes how much a result shifts the odds of disease: LR+ = sensitivity ÷ (1 − specificity); LR− = (1 − sensitivity) ÷ specificity. Because they are built only from the test’s sensitivity and specificity, likelihood ratios are independent of prevalence — which is exactly why a Fagan nomogram can turn any pre-test probability into a post-test probability.
Read the full guide →What is a Fagan nomogram?
A three-column chart: draw a line from your pre-test probability through the test’s likelihood ratio and it lands on the post-test probability. It is a visual form of Bayesian updating, and this tool draws one live.
Read the full guide →Why does repeated (serial) screening raise the chance of a false positive?
Each additional round is another chance of a false alarm. If every round has the same specificity and errors are independent, the chance of at least one false positive after n rounds is 1 − specificityⁿ (one minus specificity raised to the power n) — about 65% after ten rounds of a 90%-specific test. Independence is an assumption, not a limit: if errors are correlated the true figure can be lower or higher, anywhere from one round’s false-positive rate up to n times it (capped at 100%).
Read the full guide →What is the difference between NNT, NNH, and NNS?
NNT (number needed to treat) is how many people must be treated for one more to benefit; NNH (number needed to harm) is how many for one more to be harmed. A trial’s NNS (number needed to screen) is how many people must be offered a whole screening program to prevent one bad outcome — a program-level figure that should not be entered as a treatment NNT. This calculator also shows “screens per modeled benefit”: people screened divided by the people its illustrative treatment helps.
Read the full guide →References & sources
This is an educational model, not a description of any specific test. The example figures offered next to each control are drawn from primary literature; key sources include:
- Test accuracy — USPSTF, BCSC mammography benchmarks (Lehman, 2017), NLST low-dose CT, FIT meta-analysis (Lee, 2014), cfDNA NIPT meta-analysis (Gil, 2017).
- Cumulative false positives — Elmore et al., NEJM 1998; Croswell et al., Ann Fam Med 2009.
- Treatment benefit & harm (NNT / NNH) — Cochrane reviews and trial meta-analyses, with figures cross-checked against theNNT.com (e.g. statins, aspirin, anticoagulation, antibiotics).
Each input’s example callout links its own source. Formulas: PPV / NPV via Bayes; LR+ = sens / (1−spec); LR− = (1−sens) / spec; NNT = 1 / ARR; screens per modeled benefit = screened ÷ helped.