Sensitivity and Specificity Calculator

Enter the four cells of a diagnostic test's 2×2 table to compute sensitivity, specificity, PPV, NPV, accuracy, and prevalence.

Quick Facts

Formulas
Sensitivity = TP / (TP + FN); Specificity = TN / (TN + FP)
Sensitivity and specificity are properties of the test itself and do not change with disease prevalence.

Your Results

Calculated
Sensitivity (TPR)
-
TP / (TP + FN)
Specificity (TNR)
-
TN / (TN + FP)
Positive predictive value
-
TP / (TP + FP)
Negative predictive value
-
TN / (TN + FN)
Accuracy
-
(TP + TN) / total
Prevalence
-
(TP + FN) / total

Ready

Enter the four cell counts from your 2×2 table and press Calculate.

How to calculate sensitivity and specificity

Sensitivity and specificity describe how well a binary diagnostic test (or classifier) separates people who have a condition from people who do not. Both are computed from a 2×2 confusion matrix that cross-tabulates the test result against the true disease status, verified by a reference "gold standard".

The four cells are: true positives (TP) — has the condition and tested positive; false negatives (FN) — has the condition but tested negative; true negatives (TN) — free of the condition and tested negative; and false positives (FP) — free of the condition but tested positive.

  • Sensitivity (true positive rate, recall) = TP / (TP + FN). Of everyone who truly has the condition, the fraction the test correctly identifies.
  • Specificity (true negative rate) = TN / (TN + FP). Of everyone who is truly free of the condition, the fraction the test correctly clears.

A worked example: screening 1,000 people where 100 truly have the disease. If the test catches 90 of them (TP = 90, FN = 10) and correctly clears 860 of the 900 healthy people (TN = 860, FP = 40), then sensitivity = 90 / 100 = 0.90 (90%) and specificity = 860 / 900 ≈ 0.9556 (95.6%).

Why both numbers matter

Sensitivity and specificity trade off against each other as you move a test's classification cutoff. Lowering the cutoff catches more true cases (higher sensitivity) but also flags more healthy people (lower specificity). A test that simply calls everyone positive has 100% sensitivity and 0% specificity, which is why you must always report the pair together, not one in isolation.

Predictive values and prevalence

Sensitivity and specificity are intrinsic to the test and do not change with how common the disease is, because each is measured within a single disease-status group. What patients and clinicians usually want, though, is the reverse question answered by predictive values:

  • Positive predictive value (PPV) = TP / (TP + FP): given a positive test, the probability the person really has the condition.
  • Negative predictive value (NPV) = TN / (TN + FN): given a negative test, the probability the person is really free of it.

PPV and NPV depend heavily on prevalence. When a disease is rare, even a highly specific test produces mostly false positives, so PPV falls — the key reason population screening for rare conditions is interpreted cautiously.

Common reference points

A useful mnemonic: SnNout (a highly Sensitive test that is Negative rules a condition out) and SpPin (a highly Specific test that is Positive rules it in). Confirmatory tests are chosen for high specificity; screening tests are chosen for high sensitivity so few true cases slip through.

Frequently Asked Questions

What is the difference between sensitivity and specificity?
Sensitivity, TP / (TP + FN), is the share of people who truly have the condition that the test correctly flags. Specificity, TN / (TN + FP), is the share of people who are truly free of the condition that the test correctly clears. High sensitivity means few missed cases (false negatives); high specificity means few false alarms (false positives).
Do sensitivity and specificity change with disease prevalence?
No. Each is measured within one disease-status group, so both are properties of the test and stay constant as prevalence changes. Predictive values do change: PPV drops when the disease is rare because a larger share of positives are false positives, and NPV rises. Report sensitivity/specificity for the test and PPV/NPV for a specific population.
What is a "good" sensitivity or specificity?
It depends on the cost of each error. Screening tests favor high sensitivity (often 95%+) so true cases are not missed, accepting more false positives that follow-up testing will clear. Confirmatory tests favor high specificity so a positive is trustworthy. There is no universal threshold — the right balance is set by how harmful a false negative is versus a false positive in your context.