Test accuracy and risk
A diagnostic test's 2×2 table from counts or from sensitivity, specificity and prevalence, drawn as 1,000 people; PPV and NPV against prevalence; ROC curves with a threshold slider and AUC; alarms as a low-prevalence test; relative versus absolute risk and NNT; and why reference ranges flag healthy people.
Added · updated 14 October 2026
How to use it
Educational — not a medical device. Not for diagnosis, treatment, monitoring or dosing. The numbers here describe tests and populations, never a particular person.
Companion to Measurement, imaging and diagnostics (chapter 15) of Human Biology for the Medical Maker, with pieces from chapter 1 (reference ranges), chapter 11 (risk), chapter 12 (percentiles) and chapter 20 (alarms and model evaluation).
How to use it
-
2×2 table — enter sensitivity, specificity, prevalence and the number of people tested, or the four counts from a study. You get PPV, NPV, accuracy and likelihood ratios, and the same result drawn as 1,000 people rounded to whole people (largest-remainder rounding, so they always add to 1,000). From counts, each proportion also gets a 95 % Wilson score interval. The first example is the book’s: a test 99 % sensitive and 99 % specific, where 1 in 1,000 has the condition, gives about 110 positives in 10,000 people, of whom about 10 have it — a PPV of about 9 %.
-
Prevalence — PPV and NPV for one test across prevalences from 0.01 % to 100 % (log scale), with a table. The book’s exercise is the default: 95 % sensitivity and 90 % specificity give a PPV of 8.8 % at 1 % prevalence and 86.4 % at 40 %.
-
ROC & threshold — two groups, with and without the condition, as normal distributions of an imaginary test value. Drag the threshold to see sensitivity, specificity, and the point on the ROC curve move. AUC is Φμ1 − μ0) / √(σ0² + σ1² for this binormal model. The tool shows the trade but does not pick a threshold: where the threshold is set is a clinical and ethical decision, not a mathematical one.
-
Alarms — a monitor checking once a minute is a test run 1,440 times a day on a condition that is rare in any one minute. A detector 99 % sensitive and 99 % specific per check, with one real event a day, raises about 15 alarms, 14 of them false.
-
Risk — turn a headline ("halves your risk") into relative risk, relative and absolute risk reduction, and the number needed to treat, for a baseline risk you choose; drag the baseline to see the NNT change. Or enter two risks directly. A relative increase gives a number needed to harm. NNT is 1 ÷ ARR, rounded up. Below that, prevalence ≈ incidence × duration, with the steady-state form P / (1 − P) = I × D for comparison.
-
Reference ranges — a range built as the central 95 % of a reference population leaves 1 in 20 of those people outside it by construction. Across k independent results, 1 − 0.95k have at least one outside: about 64 % for 20 results. The same arithmetic for design: a 5th–95th percentile design excludes 10 % on one dimension and 1 − 0.9k across k independent dimensions.
A positive screen is a reason to look further, not a diagnosis.
For a single prevalence drawn as a Bayes tree, see the probability tool’s Bayes tab.
Add #roc (or #table, #prevalence, #alarms, #risk, #ranges) to the address to open that tab.
Sources
-
2×2 table, PPV arithmetic, ROC and threshold wording: chapter 15. The 99/99 table and the 95/90 exercise are the book’s.
-
RR, RRR, ARR and NNT, the 2 % → 1 % example, the 0.2 % baseline, the falls question, and prevalence ≈ incidence × duration: chapter 11; NNT = 1 ÷ ARR is also in appendix C.
-
Alarms as a test with a prevalence problem, the 72–99 % figure, and IEC 60601-1-8: chapter 20.
-
Reference ranges as the central 95 %: chapter 1. Percentile exclusion across dimensions: chapter 12.
-
Wilson score interval: E. B. Wilson (1927), J. Am. Stat. Assoc. 22:209. Normal CDF: the complementary error function approximation from Numerical Recipes (fractional error < 1.2 × 10−7).
Limits
-
Sensitivity and specificity are treated as fixed. In reality they vary with the population, the stage of disease, and how the study chose its people (spectrum bias); a study’s prevalence is rarely yours.
-
The Wilson intervals reflect sample size only, not bias in the study.
-
The ROC tab’s distributions are invented normal curves with arbitrary units. Real test values are skewed, overlapping in odd ways, and measured with error.
-
The alarm model treats every check as independent. Real alarms are correlated (one artefact trips many checks) and are shaped by delays, filters and priorities chosen with clinicians.
-
1 − pk assumes independence. Real results and body dimensions are correlated, so the true share is lower than shown, though still above the single-result figure.
-
No output here is a risk score for a person, and none of it says whether a value is "normal".
Related: probability (Bayes tree, binomial), statistics (hypothesis tests, distributions), survival analysis (Kaplan–Meier), labels, alarms and the senses (whether an alarm can be heard at all).
Sharing
Share link (under the title) copies a URL that reopens this tool with your inputs on every tab, with the current tab selected. Opening such a link replaces the inputs this browser had saved for the tool.
Linking to an example
Also a companion to Bayes' theorem in chapter 29 and precision, recall and F1 in chapter 31 of
Mathematics, Reconnected: in the book’s words, precision is
PPV and recall is sensitivity. Settings have short parameters, and the tab comes from the # part of
the address, for example
/tools/diagnostic-tests/?sens=99&spec=95&prev=1#table
or ?tp=90&fp=150&fn=10&tn=9750#table.
The risk and reference-range tabs travel only in Share link's compressed ?s=.
| Tab | Parameter | Meaning | Example |
|---|---|---|---|
|
|
sensitivity, specificity and prevalence in %, for the tab the link opens ( |
|
|
|
|
|
|
|
the four counts (switches to counts mode, and adds F1) |
|
|
|
means and SDs without and with the condition, and the threshold |
|
|
|
checks per day and real events per day |
|
|
one of the presets below (it also picks the tab); other parameters override it |
|
Presets:
-
ch29-bayes-test— 1% prevalence, 99% sensitivity, 5% false positives: a positive means about 1 in 6 -
ch29-second-test— A second positive: prior 1/6, posterior about 80% -
ch29-bayes-slider— The same test across prevalences: the posterior collapses as the disease gets rarer -
ch31-fraud-classifier— Fraud model: recall 0.90, precision 0.375, F1 ≈ 0.53, accuracy 98.4% -
ch31-threshold— Move the threshold: recall (sensitivity) against precision (PPV) at a 1% base rate
Feedback is a gift. Something to improve, a feature to add, or a bug? Tell me.
Runs entirely in your browser; nothing you type leaves this page.