This sensitivity and specificity calculator turns a test’s four outcome counts — true positives, false positives, false negatives, true negatives — into the complete diagnostic report: sensitivity, specificity, predictive values, accuracy, likelihood ratios and Youden’s index.
Four Counts, Eight Numbers, Two Different Questions
Every diagnostic test, classifier and screening program reduces to a 2×2 table, and every metric anyone quotes is a ratio of its cells. The columns are truth, the rows are the test’s verdicts, and the two families of metrics read the table in perpendicular directions. Sensitivity = TP/(TP+FN) reads down the sick column: of the truly diseased, what fraction did the test catch (the defaults: 90/100 = 90%)? Specificity = TN/(TN+FP) reads down the well column: of the truly healthy, what fraction tested negative (80/100 = 80%). The predictive values read the other way — PPV = TP/(TP+FP) = 81.8% answers “my test was positive; how likely am I actually sick?” — and they are NOT properties of the test: they depend on prevalence, which is why the same excellent test is a fine diagnostic in a clinic (high prevalence) and a false-positive factory in population screening (low prevalence). The calculator’s example population is 50% diseased by construction; rerun the mental arithmetic at 1% prevalence and PPV falls to ~8% while sensitivity and specificity don’t move a decimal.
The remaining metrics each earn their place: accuracy (85% here) is the headline number and the most misleading one (a test that calls everyone negative in a 1%-prevalence population is 99% “accurate” and clinically worthless); likelihood ratios convert test results into odds updates (LR+ 4.5 = a positive multiplies your odds of disease 4.5-fold; LR− 0.125 = a negative divides them by 8) and are prevalence-independent, which is why evidence-based medicine trades in them; Youden’s J (0.70) compresses the sens/spec pair into one number used to choose cutoffs on ROC curves; and the F1 score (2TP/(2TP+FP+FN) = 85.7% here) is the same table read by machine learning, where the confusion matrix is this exact object wearing a different name. One calculator, four professions — medicine, epidemiology, ML and quality engineering all keep arriving at this 2×2.
Worked Examples (Verified)
- Defaults: TP 90, FN 10, FP 20, TN 80 → Sens 90.0% · Spec 80.0% · PPV 81.8% · NPV 88.9% · Accuracy 85.0% · LR+ 4.50 · LR− 0.13 · J 0.70.
- The prevalence trap: same test (sens 90%, spec 80%) on 10,000 people at 1% prevalence: 90 TP, 1,980 FP → PPV = 90/2,070 = 4.3%… with specificity 95% instead, FP falls to 495 and PPV rises to 15.4% — specificity is the screening metric that pays.
- Perfect-rule-out test: FN = 0 → NPV = 100% and LR− = 0 (SnNout: a Sensitive test, when Negative, rules out).
Sensitivity & Specificity Discipline
- Never quote PPV/NPV without the prevalence they were measured at — transporting them across populations is the field’s most repeated error.
- Accuracy lies by imbalance: with rare outcomes, always read sens/spec (or the full matrix) before the headline percentage.
- Sens and spec trade along the cutoff: sliding a threshold raises one and lowers the other — Youden’s J and the ROC curve exist to choose the trade deliberately.
- Likelihood ratios chain: sequential tests multiply odds by each test’s LR (assuming conditional independence) — the arithmetic of diagnostic workups.
- Confidence intervals matter: sens 90% from 100 cases carries ±~6 points; from 20 cases, ±~13 — small validation sets produce decorative metrics.
Related Tools
- Bayes Theorem Calculator — the odds machinery behind predictive values
- Statistics Calculators — the full collection
Frequently Asked Questions
How do you calculate sensitivity and specificity?
From the 2×2 outcome table: sensitivity = TP ÷ (TP + FN) — of all truly positive cases, the fraction the test caught; specificity = TN ÷ (TN + FP) — of all truly negative cases, the fraction the test correctly cleared. With TP 90, FN 10, FP 20, TN 80: sensitivity 90%, specificity 80%. This calculator adds the rest of the family — PPV, NPV, accuracy, both likelihood ratios and Youden’s index — from the same four counts.
What is the difference between sensitivity and PPV?
They read the confusion matrix in opposite directions. Sensitivity conditions on the TRUTH: given disease, how often is the test positive? PPV (positive predictive value) conditions on the RESULT: given a positive test, how often is there disease? Sensitivity is a stable property of the test; PPV collapses as prevalence falls — the defaults’ PPV is 81.8% in a 50%-prevalence sample, but the identical test at 1% prevalence returns a PPV around 4.3%. Patients ask the PPV question; test brochures advertise the sensitivity answer; the gap between them is where screening controversies live.
What are likelihood ratios and how are they used?
LR+ = sensitivity ÷ (1 − specificity) — how much a positive result multiplies the odds of disease; LR− = (1 − sensitivity) ÷ specificity — the multiplier for a negative. Defaults: LR+ 4.50 (a moderate rule-in), LR− 0.125 (a strong-ish rule-out; below 0.1 is excellent). Use: convert your pre-test probability to odds, multiply by the LR, convert back — Bayes’ theorem in clinical pocket form, and the reason LRs are preferred for sequential testing: they don’t depend on prevalence, so they travel between populations the way predictive values can’t.
What is Youden’s index?
J = sensitivity + specificity − 1: a single score for a test’s overall discrimination at a given cutoff, from 0 (useless — the test’s verdicts carry no information) to 1 (perfect). The defaults score 0.70. Its practical job is cutoff selection: on an ROC curve, the point maximizing J is the standard “optimal” threshold — balancing the two error types equally. When the costs of the errors are unequal (missing cancer vs a false alarm), cost-weighted choices beat J — the index is a default, not a decision.
Why isn’t accuracy enough to judge a test?
Because accuracy is prevalence in disguise. At 1% disease prevalence, a “test” that declares everyone healthy scores 99% accuracy with 0% sensitivity — perfect marks, zero function. Balanced accuracy (the mean of sens and spec) fixes the weighting, but the real discipline is reading the whole matrix: which errors, how many, at what cost. The defaults here (85% accuracy, with 10 missed cases and 20 false alarms per 200) show what the headline hides — the 10 and the 20 are different clinical events with different consequences, compressed by accuracy into one indifferent number.
What makes a test good for screening vs confirmation?
Screening wants sensitivity (and NPV): cast wide, miss nobody, accept false positives that a second stage will clear — a high-sensitivity test’s NEGATIVE is trustworthy (SnNout). Confirmation wants specificity (and LR+): before a serious diagnosis or treatment, a positive must mean it — a high-specificity test’s POSITIVE rules in (SpPin). Two-stage programs chain them deliberately (sensitive screen → specific confirm, like HIV algorithms), and this calculator prices each stage: run the first test’s outputs as the second stage’s input population and the LRs multiply through.
How does the confusion matrix relate to machine learning?
It IS the machine-learning confusion matrix, unchanged: TP/FP/FN/TN, with precision = PPV, recall = sensitivity, F1 = the harmonic mean of the two, and accuracy shared verbatim. The fields diverged in vocabulary (medicine says sensitivity/PPV, ML says recall/precision) while keeping identical arithmetic — a model card reporting precision 0.82 and recall 0.90 is this calculator’s defaults in a hoodie. ROC-AUC, Youden cutoffs and prevalence caveats all transfer too; only the costumes differ.
Is this sensitivity and specificity calculator free?
Yes — free, instant, no sign-up. Enter the four counts for sensitivity, specificity, PPV, NPV, accuracy, likelihood ratios and Youden’s index.