Sensitivity and Specificity Calculator
Work out the positive and negative predictive value of a test from its sensitivity, specificity and how common the condition is, or calculate all of these directly from a results table. See why a good test can still give mostly false alarms when the condition is rare.
What do you have?
How common the condition is among people like this. Type 1%, 0.01 or 1/100.
How often the test catches a real case.
Specificity = 100% minus the false positive rate. Switching converts the number for you.
For learning only. This can't interpret your own test result. Talk to a doctor or nurse about that.
Also called a confusion matrix. Enter counts from real results, a study, or a model's output.
Assumes the scores of people without the condition and people with it each follow a normal (bell-curve) distribution. This is the standard "binormal" model used to draw a theoretical ROC curve from just two distributions, rather than raw data.
Score distribution without the condition
Score distribution with the condition
Scores at or above this count as positive. See how sensitivity and specificity trade off as you move it.
Type chances as 5%, 0.05 or 1/20.
Results update as you type. Press Calculate or Enter to save one to your recent list.
Your recent calculations
Saved only in this browser, on this device. Nothing is sent to us. Privacy
Practice questions
Five fresh questions each time, with worked answers. Teachers can print them as a worksheet with an answer key, or save it as a PDF from the print window.
Four numbers, four different questions
A test's quality is usually described with four related but different figures, and mixing them up is the single most common mistake in reading test results.
| Term | Question it answers | Formula |
|---|---|---|
| Sensitivity (recall) | Of the people who really have it, how many did the test catch? | TP / (TP + FN) |
| Specificity | Of the people who don't have it, how many did the test correctly clear? | TN / (TN + FP) |
| Positive predictive value (precision) | Of the people who tested positive, how many really have it? | TP / (TP + FP) |
| Negative predictive value | Of the people who tested negative, how many are really clear? | TN / (TN + FN) |
Sensitivity and specificity describe the test itself, and stay roughly fixed wherever it's used. PPV and NPV describe how much you can trust a specific result, and they move a great deal depending on how common the condition is in whoever's being tested. That difference is the whole point of this page.
The formulas
Turning sensitivity and specificity into PPV
PPV = (prevalence × sensitivity) / (prevalence × sensitivity + (1 − prevalence) × false positive rate)
This is Bayes' theorem, written in test terms. The false positive rate is 1 minus specificity.
Likelihood ratios
LR+ = sensitivity / (1 − specificity) LR− = (1 − sensitivity) / specificity
A positive likelihood ratio above 10, or a negative one below 0.1, is generally considered to shift a diagnosis a lot. Between 1 and 2, or 0.5 and 1, barely shifts it at all.
From a table directly
Accuracy = (TP + TN) / total F1 = 2 × precision × recall / (precision + recall)
Accuracy can look reassuring even when a test is unreliable, if the condition is rare, because correctly saying "no" to almost everyone scores well on accuracy alone. F1 balances precision (PPV) and recall (sensitivity) into one number, often used to judge classifiers in machine learning.
Worked example: the same test, two populations
A test has 95% sensitivity and a 5% false positive rate. Where 1% of people have the condition, out of 10,000 people, 100 have it and 95 test positive. Of the 9,900 without it, 495 test positive anyway. Only 95 of the 590 positives are real: a PPV of 16.1%.
Use the exact same test where 30% of people have the condition, and the PPV rises to 89.1%. Sensitivity and specificity haven't changed at all. Only the population has.
ROC curves, AUC and choosing a threshold
Most tests, and almost every machine learning classifier, don't just say yes or no. They produce a score, and someone has to pick a cutoff above which the result counts as positive. Move that cutoff and sensitivity and specificity both change, in opposite directions. A receiver operating characteristic (ROC) curve plots that whole trade-off at once: sensitivity against 1 minus specificity, for every possible cutoff.
The area under that curve, the AUC, summarises the curve in a single number between 0.5 (no better than guessing) and 1.0 (the two groups' scores never overlap). It answers a clean question: if you picked one random person with the condition and one without, what's the chance the test scores the first one higher? That's exactly what AUC measures, whatever cutoff you eventually choose. The "ROC curve and AUC" mode above lets you model two score distributions directly and see the curve, the AUC, and the sensitivity and specificity at any cutoff you try.
Mistakes that give the wrong answer
Treating sensitivity as if it were PPV. "95% sensitive" describes performance among people who have the condition. It says nothing on its own about how many positive results are real.
Ignoring prevalence. As the worked example shows, the same test gives very different answers depending on how common the condition is.
Trusting accuracy alone. A test that always says "negative" can be 99% accurate for a condition that only 1% of people have, while catching zero real cases. Sensitivity would be 0%.
Assuming a high PPV means a high NPV, or vice versa. They answer different questions and can move independently, especially when prevalence is far from 50%.
How we calculate
Results from test rates follow directly from Bayes' theorem, and show an exact fraction when your inputs are simple percentages or fractions. The picture of cases uses expected counts, rounded to whole numbers, from a group large enough that the smallest group is still visible. Results from a table are computed directly from your four counts, with no rounding until the final percentage.
The simulation creates 10,000 random cases in your browser using the rates you entered, and counts how many positives are real, so you can see the exact answer hold up under repetition. Every number in the examples on this page was checked against an independent calculation in Python. If you spot a mistake, let us know and we'll correct it and note the change here.
References
- Sheldon Ross, A First Course in Probability, 10th edition, Pearson, 2019. Chapter 3 covers conditional probability and Bayes' formula.
- NIST/SEMATECH e-Handbook of Statistical Methods, section on classification performance measures.
- Douglas G. Altman and J. Martin Bland, "Diagnostic tests 2: predictive values", BMJ, 309(6947), 1994, page 102.
Related calculators
- Bayes' Theorem Calculator, for a full walkthrough of updating a belief with new evidence, second tests and several possible causes
- Binomial Probability Calculator, including a test for whether a rate differs from what you expected
- Conditional Probability Calculator, the idea PPV and NPV are built on
- Probability Calculator, the full set of tools
Questions people ask
What's the difference between sensitivity and PPV?
Sensitivity is the share of real cases the test catches. PPV is the share of positive results that are real. They can be very different, especially when the condition is rare.
How do I find PPV if I only know sensitivity and specificity?
You also need the prevalence, how common the condition is. Use Bayes' theorem: PPV = (prevalence × sensitivity) divided by (prevalence × sensitivity plus (1 minus prevalence) times the false positive rate).
Why does the same test give a different PPV in different groups?
Because PPV depends on how many people in the group actually have the condition, not just on how good the test is. A 95%-sensitive test gives a 16.1% PPV at 1% prevalence and an 89.1% PPV at 30% prevalence.
What are precision and recall?
Machine learning names for the same ideas. Precision is the positive predictive value: the share of positive predictions that are correct. Recall is sensitivity: the share of real positives the model catches.
Can I calculate all of this from a confusion matrix?
Yes. Use "A results table" and enter your true positives, false positives, false negatives and true negatives directly. Every figure on this page, including accuracy and F1, follows from those four counts.
What does AUC mean?
The area under the ROC curve. It's the chance that a random person with the condition scores higher than a random person without it, across every possible cutoff. 0.5 is no better than guessing; 1.0 is a perfect separation between the two groups.
What is a likelihood ratio?
It says how many times more likely a result is when the condition is present than when it isn't. A positive likelihood ratio above 10 is generally seen as strong evidence; one between 1 and 2 barely moves the needle.