# A test’s sensitivity and specificity

Computes a test’s sensitivity, specificity, positive and negative predictive values, accuracy and likelihood ratios from true and false positives and negatives.

- Page: https://www.acalculator.org/statistics/sensitivity-specificity-calculator
- JSON spec: https://www.acalculator.org/statistics/sensitivity-specificity-calculator.json
- Version: 435826dff29b

## Default answer

Example with the default inputs (True positives 231, False positives 32, False negatives 27, True negatives 54): Sensitivity is 89.53% and specificity is 62.79%.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| tp | True positives | People with the condition whose test is positive. |
| fp | False positives | People without the condition whose test is positive. |
| fn | False negatives | People with the condition whose test is negative. |
| tn | True negatives | People without the condition whose test is negative. |
| prev | Prevalence in your population | Optional: the share of people with the condition where the test will be used, to rework the predictive values. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| sensitivity | Sensitivity | True positives ÷ everyone with the condition: the share the test finds. |
| specificity | Specificity | True negatives ÷ everyone without the condition: the share the test clears. |
| ppv | Positive predictive value | True positives ÷ all positive tests. |
| npv | Negative predictive value | True negatives ÷ all negative tests. |
| accuracy | Accuracy | True positives and true negatives ÷ everyone tested. |
| prevalenceTable | Prevalence in the table | Everyone with the condition ÷ everyone tested. |
| lrPositive | Positive likelihood ratio | Sensitivity ÷ (1 − specificity). |
| lrNegative | Negative likelihood ratio | (1 − sensitivity) ÷ specificity. |
| ppvAt | Positive predictive value at your prevalence | The PPV worked from the typed prevalence. |
| npvAt | Negative predictive value at your prevalence | The NPV worked from the typed prevalence. |

## Method

Sensitivity = TP ÷ (TP + FN); specificity = TN ÷ (TN + FP); PPV = TP ÷ (TP + FP); NPV = TN ÷ (TN + FN); LR+ = sensitivity ÷ (1 − specificity); LR− = (1 − sensitivity) ÷ specificity; at prevalence p, PPV = sens × p ÷ [sens × p + (1 − spec)(1 − p)].

## Assumptions

- The reference standard decides who has the condition; the counts come from one group of people tested.
- Values that would divide by zero are not shown (for example LR+ when there are no false positives).

## Worked examples

1. tp = 231, fp = 32, fn = 27, tn = 54 gives sensitivity = 89.534884%, specificity = 62.790698%, ppv = 87.8327%, npv = 66.666667%, accuracy = 82.848837%, prevalenceTable = 75%. Source: https://www.bmj.com/content/308/6943/1552.
2. tp = 42, fp = 2, fn = 106, tn = 142, prev = 10% gives sensitivity = 28.378378%, specificity = 98.611111%, lrPositive = 20.432432, lrNegative = 0.726304, ppvAt = 69.421488%. Source: https://pmc.ncbi.nlm.nih.gov/articles/PMC478236/.
3. tp = 90, fp = 0, fn = 10, tn = 100 gives sensitivity = 90%, specificity = 100%, ppv = 100%, npv = 90.909091%, lrNegative = 0.1. Source: https://www.bmj.com/content/308/6943/1552.

## FAQ

### How do I calculate sensitivity?

Divide the true positives by everyone who has the condition: TP ÷ (TP + FN). In the liver scan study, 231 of the 258 patients with abnormal pathology had an abnormal scan: 231 ÷ 258 = 89.5%.

### How do I calculate specificity?

Divide the true negatives by everyone who does not have the condition: TN ÷ (TN + FP). In the same study, 54 of 86 patients with normal pathology had a normal scan: 54 ÷ 86 = 62.8%.

### What is the difference between sensitivity and positive predictive value?

Sensitivity starts from the people who have the condition and asks how many test positive. The positive predictive value starts from the people who test positive and asks how many have the condition: TP ÷ (TP + FP).

### Why do predictive values change with prevalence?

When a condition is rare, most people tested do not have it, so even a few false positives can outnumber the true positives. Sensitivity and specificity stay the same, but the PPV falls. Type a prevalence to see the PPV and NPV for your population.

### What is a likelihood ratio?

The positive likelihood ratio is sensitivity ÷ (1 − specificity): how much more often a positive result occurs in people with the condition than in people without it. The negative likelihood ratio is (1 − sensitivity) ÷ specificity.

### Why is a value missing?

A value that would divide by zero is not shown. With no false positives, specificity is 100% and the positive likelihood ratio is infinite. With no positive tests at all, there is no positive predictive value.

## Sources

- Altman DG, Bland JM. Statistics Notes: Diagnostic tests 1: sensitivity and specificity. BMJ 1994;308:1552, retrieved 2026-10-18. https://www.bmj.com/content/308/6943/1552 (index: https://pmc.ncbi.nlm.nih.gov/articles/PMC2540489/)
- Altman DG, Bland JM. Statistics Notes: Diagnostic tests 2: predictive values. BMJ 1994;309:102, retrieved 2026-10-18. https://www.bmj.com/content/309/6947/102.1
- Deeks JJ, Altman DG. Statistics Notes: Diagnostic tests 4: likelihood ratios. BMJ 2004;329:168-169, retrieved 2026-10-18. https://pmc.ncbi.nlm.nih.gov/articles/PMC478236/
- Centers for Disease Control and Prevention. Guidelines for Evaluating Surveillance Systems. MMWR 1988;37(S-5) (sensitivity A/(A+C), predictive value positive A/(A+B)), retrieved 2026-10-18. https://www.cdc.gov/mmwr/preview/mmwrhtml/00001769.htm
