Sensitivity and Specificity Calculator (PPV, NPV, 2×2 Table)

Enter the four cells of a 2×2 table to get sensitivity, specificity, PPV, NPV, likelihood ratios, accuracy and prevalence. Switch to risk mode for relative risk, odds ratio, absolute risk reduction and number needed to treat. Formulas are shown with every result.

Free · Formulas from NIH StatPearls and PubMed Central · Last checked 24 October 2026

Disease presentDisease absentTest positiveTest negative

For exam study, not for clinical use.

How it works

Diagnostic test (2×2 table)

Sensitivity and specificity

Sensitivity = TP / (TP + FN): the share of people with the disease who test positive.

Specificity = TN / (TN + FP): the share of people without the disease who test negative.

Source: Diagnostic Testing Accuracy: Sensitivity, Specificity, Predictive Values and Likelihood Ratios (NCBI Bookshelf, NIH) [1]

Predictive values

PPV = TP / (TP + FP): of all positive results, how many are true positives.

NPV = TN / (TN + FN): of all negative results, how many are true negatives.

Prevalence changes PPV and NPV: when a disease is common, a test is better at ruling it in and worse at ruling it out.

Source: Diagnostic Testing Accuracy: Sensitivity, Specificity, Predictive Values and Likelihood Ratios (NCBI Bookshelf, NIH) [1]

Likelihood ratios

LR+ = sensitivity / (1 − specificity)

LR− = (1 − sensitivity) / specificity

Like sensitivity and specificity, likelihood ratios are not affected by prevalence.

Source: Diagnostic Testing Accuracy: Sensitivity, Specificity, Predictive Values and Likelihood Ratios (NCBI Bookshelf, NIH) [1]

Accuracy and prevalence

Accuracy = (TP + TN) / (TP + TN + FP + FN): the share of all people classified correctly. It is affected by prevalence. As prevalence rises, PPV rises and NPV falls.

Prevalence = (TP + FN) / total: people with the disease out of everyone in the table.

Source: Simundic AM (PubMed Central, NIH) [2]; Foundational Statistical Principles in Medical Research: A Tutorial on Odds Ratios, Relative Risk, Absolute Risk, and Number Needed to Treat (PubMed Central, NIH) [3]

Risk mode (exposure and outcome)

Relative risk and odds ratio

RR = [a / (a + b)] / [c / (c + d)]: risk with exposure divided by risk without it. RR = 1 means no difference; above 1, the event is more likely with exposure; below 1, less likely.

OR = (a / b) / (c / d) = ad / bc. When the event is rare the OR and RR are similar; when it is common the OR overestimates the risk. RR suits cohort studies, where exposure status is known for everyone.

Source: Relative Risk (NCBI Bookshelf, NIH) [4]

Absolute risk, RRR and NNT

ARR = risk in control − risk in treated (when the treatment lowers risk). ARI = risk in exposed − risk in unexposed (when the exposure raises risk).

RRR = 1 − RR, the percent decrease in risk.

NNT = 1 / ARR and NNH = 1 / ARI: the average number of people who must be treated (or exposed) for one extra outcome.

Source: Foundational Statistical Principles in Medical Research: A Tutorial on Odds Ratios, Relative Risk, Absolute Risk, and Number Needed to Treat (PubMed Central, NIH) [3]; Tips for learners of evidence-based medicine: 1 (PubMed Central, NIH) [5]

Worked examples

Diagnostic test (StatPearls worked example): TP 369, FP 58, FN 15, TN 558.

  • Sensitivity = 369 / 384 = 96.1%; specificity = 558 / 616 = 90.6%.
  • PPV = 369 / 427 = 86.4%; NPV = 558 / 573 = 97.4%.
  • LR+ = 0.961 / 0.094 = 10.2 (StatPearls shows 10.22 after rounding; unrounded it is 10.21); LR− = 0.039 / 0.906 = 0.043.

Press Example: StatPearls test above to load it.

Source: Diagnostic Testing Accuracy: Sensitivity, Specificity, Predictive Values and Likelihood Ratios (NCBI Bookshelf, NIH) [1]

Drug trial (dutasteride and prostate cancer, from the PubMed Central tutorial): treated 659 with cancer, 2646 without; placebo 858 with cancer, 2566 without.

  • Risk treated = 659 / 3305 = 0.20; risk placebo = 858 / 3424 = 0.25.
  • RR = 0.20 / 0.25 = 0.80, so RRR = 20%.
  • ARR = 5.1%, so NNT = 1 / 0.051 = about 20 men treated to prevent one cancer.

Press Example: drug trial in risk mode to load it.

Source: Foundational Statistical Principles in Medical Research: A Tutorial on Odds Ratios, Relative Risk, Absolute Risk, and Number Needed to Treat (PubMed Central, NIH) [3]

FAQ

How do you calculate sensitivity?

Sensitivity = true positives / (true positives + false negatives). It is the share of people who have the disease and test positive.

Source: Diagnostic Testing Accuracy: Sensitivity, Specificity, Predictive Values and Likelihood Ratios (NCBI Bookshelf, NIH) [1]

What does 95% sensitivity mean?

Out of every 100 people who have the disease, the test is positive in 95. The other 5 are false negatives.

Source: Diagnostic Testing Accuracy: Sensitivity, Specificity, Predictive Values and Likelihood Ratios (NCBI Bookshelf, NIH) [1]

What is the formula for calculating positive predictive value?

PPV = true positives / (true positives + false positives): out of all positive results, the share that are true positives.

Source: Diagnostic Testing Accuracy: Sensitivity, Specificity, Predictive Values and Likelihood Ratios (NCBI Bookshelf, NIH) [1]

How do you calculate positive predictive value from sensitivity and specificity?

You also need the prevalence, because PPV changes with it. Take a group (say 1,000 people), split it into people with and without the disease using the prevalence, then fill the table: TP = sensitivity × people with the disease, FP = (1 − specificity) × people without it. PPV = TP / (TP + FP).

Source: Diagnostic Testing Accuracy: Sensitivity, Specificity, Predictive Values and Likelihood Ratios (NCBI Bookshelf, NIH) [1]

What are the key differences between a likelihood ratio and a predictive value?

Likelihood ratios are built only from sensitivity and specificity, so they are not affected by prevalence. Predictive values are: when a disease is more common, PPV rises and NPV falls.

Source: Diagnostic Testing Accuracy: Sensitivity, Specificity, Predictive Values and Likelihood Ratios (NCBI Bookshelf, NIH) [1]; Simundic AM (PubMed Central, NIH) [2]

What is the difference between relative risk and odds ratio?

Relative risk compares probabilities: [a / (a + b)] / [c / (c + d)]. The odds ratio compares odds: ad / bc. They are close when the event is rare; when it is common, the odds ratio overestimates the risk.

Source: Relative Risk (NCBI Bookshelf, NIH) [4]

How do you calculate NNT?

NNT = 1 / absolute risk reduction, where ARR = risk in the control group − risk in the treated group. Example: an ARR of 5.1% gives an NNT of about 20.

Source: Tips for learners of evidence-based medicine: 1 (PubMed Central, NIH) [5]; Foundational Statistical Principles in Medical Research: A Tutorial on Odds Ratios, Relative Risk, Absolute Risk, and Number Needed to Treat (PubMed Central, NIH) [3]

Sources

Every formula, cutoff and reference value on this page comes from the official sources below. Click any source to check it yourself.

  1. Diagnostic Testing Accuracy: Sensitivity, Specificity, Predictive Values and Likelihood Ratios. StatPearls (updated 6 March 2023) (NCBI Bookshelf, NIH)
  2. Simundic AM. Measures of Diagnostic Accuracy: Basic Definitions. EJIFCC 2009;19(4):203 (PubMed Central, NIH)
  3. Foundational Statistical Principles in Medical Research: A Tutorial on Odds Ratios, Relative Risk, Absolute Risk, and Number Needed to Treat. Int J Environ Res Public Health 2021;18:5669 (PubMed Central, NIH)
  4. Relative Risk. StatPearls (updated 27 March 2023) (NCBI Bookshelf, NIH)
  5. Tips for learners of evidence-based medicine: 1. Relative risk reduction, absolute risk reduction and number needed to treat. CMAJ 2004;171(4):353 (PubMed Central, NIH)

Last checked: 24 October 2026. Spotted a mistake? Please tell us on the Corrections page.

For exam study, not for clinical use. This tool is for learning how the formulas work. It is not medical advice. See the Medical disclaimer.

More free tools