Math calculator

ROC Curve & AUC Calculator

Every cutoff, and the area they enclose.

Every threshold, and the area

Twelve with the condition and twelve without. AUC 0.95138889 by the trapezoid rule and 137 / 144 = 0.95138889 from the Mann–Whitney U — the same number to every digit, because the AUC IS the probability a random positive outranks a random negative.

12 with the condition, 12 without, 25 thresholds

AUC = 0.95138889

95% CI 0.8593 to 1.0000 (Hanley–McNeil), p = 7.4265e-22 against an AUC of 0.5. Computed a second way as U / (n₀ × n₁) = 137 / 144 = 0.95138889 — the two paths agree to every digit.

AUC (trapezoid)

0.951389

area under the curve

AUC (Mann–Whitney)

0.951389

U = 137

Best Youden J

0.75000

at a cutoff of 2.2000

At that cutoff

91.7% / 83.3%

sensitivity / specificity

The curve, one point per threshold

00.5100.51False positive rate (1 − specificity)Sensitivity
Every candidate cutoff with its confusion matrix, sensitivity, specificity and Youden index
CutoffTPFPFNTNSensitivitySpecificityYouden J
0.40000121200100.0%0.0%0.0000
0.60000121101100.0%8.3%0.0833
0.90000121002100.0%16.7%0.1667
1.1000012903100.0%25.0%0.2500
1.2000012804100.0%33.3%0.3333
1.4000012705100.0%41.7%0.4167
1.6000012606100.0%50.0%0.5000
1.8000012507100.0%58.3%0.5833
1.9000012408100.0%66.7%0.6667
2.000001141891.7%66.7%0.5833
2.100001131991.7%75.0%0.6667
2.2000011211091.7%83.3%0.7500
2.3000010221083.3%83.3%0.6667
2.4000010121183.3%91.7%0.7500
2.600009131175.0%91.7%0.6667
2.700009031275.0%100.0%0.7500
2.900008041266.7%100.0%0.6667
3.100007051258.3%100.0%0.5833
3.300006061250.0%100.0%0.5000
3.500005071241.7%100.0%0.4167
3.800004081233.3%100.0%0.3333
4.000003091225.0%100.0%0.2500
4.2000020101216.7%100.0%0.1667
4.600001011128.3%100.0%0.0833
5.600000012120.0%100.0%0.0000

The AUC does not depend on prevalence, which is why it survives being computed on a case-control sample. What a chosen cutoff is worth in practice does depend on prevalence, and that calculation lives on the likelihood ratio calculator.

AUC = P(a random positive outranks a random negative) Every observed score is enumerated as a cutoff Youden J weights both errors equally, which is a choice

What this tool shows

The AUC is computed twice from your data — by the trapezoid rule over every enumerated threshold, and as the Mann–Whitney U divided by n₀×n₁ — and across 300 random datasets the two never differ by more than 1.11×10⁻¹⁶. That is not a coincidence to be noted: the AUC IS the probability that a randomly chosen positive outranks a randomly chosen negative, and the tool shows both paths so you can see it rather than take it on trust.

  • The full ROC curve, one point per observed score — no binning, no smoothing
  • AUC by the trapezoid rule and independently as U / (n₀ × n₁)
  • A 95% confidence interval by Hanley–McNeil, and the test against AUC = 0.5
  • Sensitivity, specificity and the full confusion matrix at every cutoff
  • The Youden-optimal threshold, named rather than left to be read off a chart
  • Complete separation reported as an undefined p-value rather than as p = 1
Every threshold Two AUC paths Youden cutoff Hanley–McNeil CI

The AUC ignores prevalence. A chosen cutoff cannot.

Updated 12 September 2026 · Works in any browser, no installation

An ROC curve plots sensitivity against 1 − specificity at every possible cutoff, and the area under it is the probability that a randomly chosen case scores above a randomly chosen non-case. That probability is exactly the Mann–Whitney U statistic rescaled, which is why an AUC can be computed without ever drawing the curve — and why it is unaffected by how many cases there are relative to non-cases.

At a glance

Formula shown
Sensitivity = TP/(TP+FN) and specificity = TN/(TN+FP) at each cutoff; the curve is (1 − specificity, sensitivity) across all of them. AUC = Σ over consecutive points of (Δ FPR)·(mean sensitivity) by the trapezoid rule, and identically AUC = U/(n₀·n₁) where U = R₁ − n₁(n₁+1)/2 and R₁ is the rank sum of the positive group. Youden’s J = sensitivity + specificity − 1, maximised to pick a cutoff when both errors cost the same.
Scenario support
Diagnostic test evaluation, biomarker and screening-cutoff selection, credit and fraud scoring, machine-learning classifier comparison, triage rules, and any setting where a continuous score has to be turned into a yes/no decision and the threshold is still open.
Educational estimate
Planning support from the values you enter — not professional advice.

The AUC is a probability, and the U statistic counts it

“Area under the curve” sounds geometric and arbitrary. It is neither, and the second computation is what makes that concrete.

Take every case-and-non-case pair and ask which scored higher. The fraction where the case wins — counting ties as half — is the AUC. With 12 positives and 12 negatives there are 144 such pairs, and the tool’s first preset has the positive winning 137 of them: 137/144 = 0.95138889.

The trapezoid area over the enumerated thresholds gives 0.95138889 as well. Not approximately — the two agree to every digit, and across 300 random datasets the largest disagreement is 1.11×10⁻¹⁶, which is floating-point noise.

Which is why the AUC is also the Mann–Whitney U test statistic. The rank test for “do these two groups differ?” and the area under a diagnostic curve are the same arithmetic asked two ways.

And it makes 0.5 interpretable rather than conventional. An AUC of 0.5 means a case outranks a non-case exactly half the time, which is what a coin does. An AUC of 0.95 means it happens 19 times in 20.

The AUC survives prevalence; a cutoff does not

This is the property that makes the AUC useful and the same property that makes it insufficient on its own.

Sensitivity and specificity are computed within groups, so changing how many non-cases you sampled changes neither. That is why an AUC computed on a case-control study, where the researcher chose the ratio, is still meaningful.

Positive predictive value is not computed within groups, and it collapses as the condition becomes rarer. A cutoff with 90% sensitivity and 90% specificity has a PPV of 50% at 10% prevalence and 8.3% at 1%.

So a paper reporting only “AUC 0.92” has not told you whether the test is usable. It has told you the ranking is good. What a positive result means at your prevalence is the likelihood ratio calculation, and it is a different number.

The precision-recall curve is the prevalence-sensitive alternative and is the more honest summary when positives are rare, precisely because it moves when the base rate does.

Youden J assumes the two errors cost the same

The tool names the Youden-optimal threshold because it is the standard default, not because it is the right answer for any particular decision.

J = sensitivity + specificity − 1 weights a missed case and a false alarm equally. It is the point furthest above the diagonal, and it is a defensible choice only when the two mistakes are genuinely comparable.

They usually are not. Missing an aggressive cancer and calling back a healthy patient for a second scan are not the same error, and no summary statistic can decide that for you.

The cost-weighted optimum sits where the curve’s slope equals (cost ratio) × (1−prevalence)/prevalence, which moves the cutoff toward sensitivity as the condition gets rarer or a miss gets more expensive.

Which is why the tool prints every cutoff rather than only the best one. The full table is what lets you pick the threshold your decision actually needs, and reading sensitivity and specificity off a chart by eye is how cutoffs get chosen badly.

An AUC below 0.5 is a good marker pointing backwards

It looks like a failure and is usually a sign convention. The fourth preset makes the point by reversing a perfect marker.

An AUC of 0 means every positive scored BELOW every negative. That is perfect separation, in the opposite direction — flip the sign of the score and the AUC becomes 1.

In general, reversing the score gives 1 − AUC, so a marker at 0.35 is equivalent to one at 0.65 and should be reported as such rather than discarded.

But choosing the direction AFTER seeing the data is a selection. If the direction was not specified in advance, the effective test is two-sided and the p-value should reflect that.

On real data an AUC slightly below 0.5 usually means no signal at all, since the sampling distribution of a useless marker is centred on 0.5 and half of its draws land below.

The confidence interval, and where it stops working

The Hanley–McNeil standard error is the standard closed form, and it has a failure mode the tool refuses to paper over.

It assumes an exponential model for the score distributions, which makes it a reasonable approximation in the middle and progressively worse as the AUC approaches 1.

At complete separation the variance is exactly zero. The formula then produces a standard error of 0, a confidence interval of zero width and — if you divide by it — a test statistic of 0/0. Software that reports p = 1 there is claiming no evidence for the strongest result the data can produce.

This tool returns an undefined p-value in that case and says so, which is the only honest output. The third preset triggers it.

For small samples or an AUC near 1, a bootstrap interval is the better tool, since it makes no distributional assumption and does not degenerate. The closed form is a convenience, not a gold standard.

Reporting an ROC analysis

Four things, and the last one is what separates a validated cutoff from a fitted one.

Report the AUC with a confidence interval and both group sizes. An AUC of 0.85 from 10 cases and an AUC of 0.85 from 500 are very different claims, and only the interval shows it.

Report sensitivity and specificity AT the cutoff you propose, not only the AUC. The area summarises every threshold; a deployed test uses one.

Say how the cutoff was chosen. Youden, a fixed sensitivity target, or a cost-weighted optimum are different decisions with different consequences.

And report cutoff performance on data that did not choose it. A threshold picked to maximise J on a sample will look better on that sample than it ever will again — the same optimism that inflates any statistic selected on its own data.

Sources and methodology

References for the ROC curve, the AUC and its standard error.

Method. Thresholds are enumerated at every observed score plus one above the maximum, so the curve passes through (0, 0) and (1, 1) exactly rather than by extrapolation, and no binning or smoothing is applied. The AUC is then computed twice by genuinely different routes — the trapezoid rule over those points, and the Mann–Whitney U with midranks for ties divided by n₀n₁ — and the suite asserts their agreement across 300 generated datasets, where the largest observed difference is 1.11×10⁻¹⁶. The p-value uses the normal survival function rather than 1 − CDF, so a strong result reports 7.43×10⁻²² instead of underflowing to zero. Complete separation returns an undefined p-value rather than 1. Fewer than three pairs, or a sample with only one outcome present, returns no result. That engine is verified on every change against 115 assertions. The count and the per-case breakdown are published on the formula verification page.

Related calculators

Where this goes next:

Sensitivity and SpecificitySensitivity, specificity, PPV, NPV, likelihood ratios and MCC from a 2×2 table, with predictive values recomputed across the prevalence range — a 99%/99% test has a PPV of 50% at 1% prevalence and 9% at 0.1%.
Likelihood RatioLR+ and LR- with post-test probability after both results, and the base-rate sweep: a 90/90 test moves a patient 0.79 points at a 0.1% pre-test and 49.41 points at 30%.
Mann-Whitney UMann-Whitney U with the tie correction and both medians shown, because it is not a test of medians — two samples with identical medians of 4 are separated at p = 0.01.
Odds RatioOdds ratio, relative risk, risk difference and number needed to treat from one 2x2 table — because an odds ratio of 6.00 can describe a relative risk of 1.50.
Relative RiskRisk ratio and odds ratio from one table with the divergence between them plotted: they agree to half a percent at a 1% baseline, and at an 80% baseline the odds ratio is exactly half the risk ratio.
Wilson Score IntervalWilson, Wald, Agresti-Coull and Clopper-Pearson on one set of counts, with the EXACT coverage each delivers at your sample size — a "95%" Wald interval covers the truth 80.85% of the time at n = 30, p = 0.1.

More in Math, or browse all calculators.

Educational use disclaimer

An educational tool. The AUC summarises ranking across every threshold and is deliberately blind to prevalence, so a high value does not mean a positive result is likely to be correct at your base rate — and a cutoff chosen to maximise performance on a sample will perform worse on any other.

How we calculate · Found an error? email us

Authorship & verification

Written and maintained by , a business operator who builds spreadsheet-based calculators.

What's changed (5 updates)

Published 12 September 2026

  1. Published an ROC tool that enumerates every observed score as a candidate cutoff rather than binning or smoothing, so the curve passes through (0,0) and (1,1) exactly and every point comes with its full confusion matrix.
  2. Computed the AUC twice by genuinely different code paths — the trapezoid rule over those points, and the Mann-Whitney U with midranks divided by n0*n1 — and asserted their agreement across 300 generated datasets. The largest disagreement is 1.11e-16, which is floating-point noise, and the identity holds on heavily tied scores where a naive implementation of either would drift.
  3. Refused to report p = 1 under complete separation. The Hanley-McNeil variance is exactly zero there, so the tool returns an undefined p-value and says why, rather than claiming no evidence for the strongest result the data can produce.
  4. Fixed a p-value underflow before it shipped: 1 - normalCdf(9.68) returns exactly 0 in double precision, so the engine uses the survival function and reports 7.43e-22.
  5. Recorded that an AUC below 0.5 is a good marker pointing backwards — reversing the score gives exactly 1 - AUC, asserted across 120 random datasets — rather than a worthless one.

Add this calculator to your site

Responsive embed — and private: nothing your visitors type leaves their browser.