Statistics & probability

Diagnostic test calculator (sensitivity, specificity, predictive values)

Work out sensitivity, specificity, predictive values, likelihood ratios and more from a 2×2 table, each with a confidence interval.

Diagnostic test calculator (sensitivity, specificity, predictive values)
Esc to restore

Your inputs

How common the condition is where the test will be used, for example 2 for 2%.

Results update as you type. Larger files run when you press Update result.

Your result

Your result will appear here.

More actions

Your inputs stay in this browser. Nothing is uploaded, and nothing is saved unless you choose “Save result”.

A clear answer. Here’s how.

From the counts TP, FP, FN and TN: sensitivity = TP ÷ (TP + FN), specificity = TN ÷ (TN + FP), positive and negative predictive values TP ÷ (TP + FP) and TN ÷ (TN + FN), accuracy, prevalence and balanced accuracy (the mean of sensitivity and specificity). Proportions get Wilson score intervals, which stay inside 0–100% and work near the edges where the simple Wald interval fails. Youden’s J = sensitivity + specificity − 1 and balanced accuracy get Wald intervals from the two binomial variances, clipped to their ranges. LR+ = sensitivity ÷ (1 − specificity), LR− = (1 − sensitivity) ÷ specificity and the diagnostic odds ratio (TP × TN) ÷ (FP × FN) get log intervals (Simel, Samsa and Matchar 1991); when any cell is zero, 0.5 is added to every cell for these three only, so they stay finite. F1 = 2TP ÷ (2TP + FP + FN) and the Matthews correlation are given without intervals. Predictive values in the sample assume the sample prevalence; at another prevalence p they follow from Bayes’ theorem, PPV = sens·p ÷ (sens·p + (1 − spec)(1 − p)), with logit intervals from the likelihood-ratio intervals (none when a cell is zero). It assumes the reference standard is correct and the cases are representative; it is not a clinical decision tool. It is a calculator, not a substitute for a statistician when decisions depend on the answer.

How this is checked

4 reference checks passed These 4 cases were run when this page was built, on 20 October 2026, and all reproduce within the stated tolerance. The same cases are part of the automated tests that run on every change to Toolmoz. Engine version 1.

See the checks and where each expected answer comes from
  1. Case 1

    Inputs
    The tool’s default inputs
    Expected, and what Toolmoz gave
    Sensitivity expected 66.66666666666667, Toolmoz 66.66666666666666Specificity expected 91, Toolmoz 91Positive predictive value expected 10, Toolmoz 10Negative predictive value expected 99.4535519125683, Toolmoz 99.4535519125683Positive likelihood ratio (LR+) expected 7.407407407407407, Toolmoz 7.407407407407409Negative likelihood ratio (LR−) expected 0.3663003663003663, Toolmoz 0.36630036630036633Sensitivity: 95% CI lower expected 48.780051644543846, Toolmoz 48.78005164454397Sensitivity: 95% CI upper expected 80.76950191632386, Toolmoz 80.76950191632378
    Where the expected answer comes from
    Wikipedia’s faecal occult blood worked example (TP 20, FP 180, FN 10, TN 1820): sensitivity 66.7%, specificity 91%, PPV 10%, NPV 99.5%, LR+ 7.4 and LR− 0.37; the Wilson limits (x + z²/2 ± z√(x(n − x)/n + z²/4)) ÷ (n + z²) for 20 of 30 from an independent Python decimal script
    Allowed difference
    ±1e-9
  2. Case 2

    Inputs
    Predictive values customOther prevalence (%) 10
    Expected, and what Toolmoz gave
    Positive predictive value at 10% prevalence expected 45.146726862302486, Toolmoz 45.146726862302486Positive predictive value at 10% prevalence: 95% CI lower expected 38.13994266212892, Toolmoz 38.13994266212898Positive predictive value at 10% prevalence: 95% CI upper expected 52.35137536665337, Toolmoz 52.35137536665334Negative predictive value at 10% prevalence expected 96.08916699256942, Toolmoz 96.08916699256942
    Where the expected answer comes from
    Bayes: PPV = (2/3 × 0.1) ÷ (2/3 × 0.1 + 0.09 × 0.9) = 0.06667 ÷ 0.14767; logit limits logit(0.1) + ln 7.407 ± 1.96 × √(1/20 − 1/30 + 1/180 − 1/2000), independent Python script
    Allowed difference
    ±1e-9
  3. Case 3

    Inputs
    True positives (test positive, condition present) 8False positives (test positive, condition absent) 3False negatives (test negative, condition present) 2True negatives (test negative, condition absent) 17
    Expected, and what Toolmoz gave
    Sensitivity: 95% CI lower expected 49.016247153664175, Toolmoz 49.01624715366438Specificity: 95% CI upper expected 94.76312541037834, Toolmoz 94.76312541037831Positive likelihood ratio (LR+): 95% CI lower expected 1.7961619238981839, Toolmoz 1.796161923898197Diagnostic odds ratio expected 22.666666666666668, Toolmoz 22.666666666666668Diagnostic odds ratio: 95% CI upper expected 163.6289416219339, Toolmoz 163.62894162193174F1 score expected 0.7619047619047619, Toolmoz 0.7619047619047619Matthews correlation coefficient expected 0.635850784457874, Toolmoz 0.635850784457874
    Where the expected answer comes from
    Small table by hand: DOR = (8 × 17) ÷ (3 × 2) = 68/3, F1 = 16/21, MCC = (136 − 6) ÷ √(11 × 10 × 20 × 19); Wilson and log limits from an independent Python decimal script
    Allowed difference
    ±1e-9
  4. Case 4

    Inputs
    True positives (test positive, condition present) 9False positives (test positive, condition absent) 0False negatives (test negative, condition present) 1True negatives (test negative, condition absent) 10
    Expected, and what Toolmoz gave
    Specificity expected 100, Toolmoz 100Specificity: 95% CI lower expected 72.24672001371108, Toolmoz 72.24672001371135Specificity: 95% CI upper expected 100, Toolmoz 100Positive likelihood ratio (LR+) expected 19, Toolmoz 19.000000000000018Diagnostic odds ratio expected 133, Toolmoz 133Youden’s J: 95% CI upper expected 1, Toolmoz 1
    Where the expected answer comes from
    Zero false positives: the Wilson lower limit for 10 of 10 is exactly n ÷ (n + z²); with 0.5 added to every cell LR+ = (9.5/10.5) ÷ (0.5/10.5) = 19 and DOR = (9.5 × 10.5) ÷ (0.5 × 1.5) = 133; J = 0.9 + 1.96 × 0.0949 is above 1, so it is clipped
    Allowed difference
    ±1e-9

What this shows: the engine reproduces independently worked values for these cases. It does not prove every possible input is right. To test an answer you were given, see how to check a number; to see what is and is not checked across Toolmoz, see the accuracy ledger.

See a worked example

Worked example

A fixed demonstration, separate from the values you enter above.

True positives (test positive, condition present)
20
False positives (test positive, condition absent)
180
False negatives (test negative, condition present)
10
True negatives (test negative, condition absent)
1820
Predictive values
At the prevalence in these data
Confidence level
95%

Example result

First 5 rows of the example result
MeasureEstimate95% CI lower95% CI upperInterval method
Sensitivity66.67%48.78%80.77%Wilson score
Specificity91.00%89.67%92.18%Wilson score
Positive predictive value10.00%6.57%14.94%Wilson score
Negative predictive value99.45%99.00%99.70%Wilson score
Accuracy90.64%89.30%91.83%Wilson score

Proportions use Wilson score intervals, which behave well near 0% and 100%. Likelihood ratios and the diagnostic odds ratio use log intervals. Predictive values depend on prevalence: the sample values only apply where the condition is as common as in this sample. These describe test accuracy in this sample, not a clinical decision for an individual.