The empirical ROC curve and its area (AUC) from scores of declared positives and negatives, version 2.0.1
stats-roc@2.0.1: this version's equations with their symbols, each constant's value, their sources and whether each was read, a worked example where the record holds one, its level and what it was checked against, the number of cases, and what was not checked. This version's record is not rewritten; a correction is added under Changes.
What this page can and cannot show
Level: Checked against a reference; Software and hand-worked checks; the half for ties from algebra, not a source read; no AUC interval. Reference kind: an outside program, scikit-learn; SciPy, scikit-learn 1.9.1; scipy 1.18.1; our own exact-arithmetic script and a hand-worked case; a reference program this project wrote itself, second implementation by a fresh agent (Python 3.13, standard library), 2026-11-14, counts and 2U in integers; the AUC as an exact rational rounded once to a double; the fractions and Youden's J in double precision as the record writes them; not an outside program.
Checked by this project, not independently reviewed. Every method on this page has its equations, constants, sources and cases on record, and its cases agree with the stated reference within the stated tolerance. A reader can follow each method's worked example by hand; that shows the stated method gives the stated answer for one set of inputs, and does not test the code. The other cases and their values are not printed, so a reader cannot re-run these checks. No independent scientist has yet reviewed them.
Every version of this method · Every method · What the levels mean
Version 2.0.1
Level: Checked against a reference; Software and hand-worked checks; the half for ties from algebra, not a source read; no AUC interval. Reference kind: an outside program, scikit-learn; SciPy, scikit-learn 1.9.1; scipy 1.18.1; our own exact-arithmetic script and a hand-worked case; a reference program this project wrote itself, second implementation by a fresh agent (Python 3.13, standard library), 2026-11-14, counts and 2U in integers; the AUC as an exact rational rounded once to a double; the fractions and Youden's J in double precision as the record writes them; not an outside program. stats-roc@2.0.1
Built, not hosted. Generated from a snapshot of the library's records taken on 2026-11-25, as committed on 2026-11-25. A later snapshot replaces this one, so these records and this page can change.
Verification statement: Points and AUC against scikit-learn 1.9.1 and SciPy 1.18.1; a hand-worked case by exact arithmetic; the ½ for ties from the trapezoid's algebra, not from a source read; no AUC interval in this version
From the scores of the declared positives and negatives and the stated direction, the empirical ROC points at every distinct threshold (counts, true- and false-positive fractions and Youden's J) and the area under the curve as the Mann–Whitney probability; no interval on the area in this version.
- How results are reported: none: counts exact; fractions and the area in full double precision
- Uncertainty: No interval on the AUC in this version: its sources are not read.
- Every reply through it says: Youden's J at each threshold describes these data; it is not a recommended cut-off.
- Reference, as its record states it: scikit-learn 1.9.1 and SciPy 1.18.1
- Level confirmed by this project's ruling of 17 November 2026
What this page can and cannot show
What was checked
82 cases in 3 files, linked by this exact version.
Run through the tool at build against an outside program, scikit-learn; SciPy, scikit-learn 1.9.1; scipy 1.18.1; our own exact-arithmetic script and a hand-worked case; a reference program this project wrote itself, second implementation by a fresh agent (Python 3.13, standard library), 2026-11-14, counts and 2U in integers; the AUC as an exact rational rounded once to a double; the fractions and Youden's J in double precision as the record writes them; not an outside program: 52 agree within the tolerance the file states, 30 refuse as the case expects, 0 differ, 0 were not run.
File 1, 11 cases
- Where the expected values came from: an outside program, scikit-learn; SciPy scikit-learn 1.9.1; scipy 1.18.1
- Recorded on: 2026-11-14
- Reference: scikit-learn; SciPy, scikit-learn 1.9.1; scipy 1.18.1; licence BSD-3-Clause
- Tolerance as the file states it: counts, U (a half-integer), thresholds and the points' fractions exact; the AUC relative 1e-15 (absolute 1e-215 below 1e-200); Youden's J absolute 1e-15; statuses, states and codes exact
File 2, 9 cases
- Where the expected values came from: our own exact-arithmetic script and a hand-worked case
- Recorded on: 2026-11-14
- Reference: exact arithmetic, 3.13.18; licence PSF-2.0
- Tolerance as the file states it: exact: every value a short binary fraction; statuses, states and codes exact
File 3, 62 cases
- Where the expected values came from: an outside program, second implementation by a fresh agent (Python 3.13, standard library) 2026-11-14
- Recorded on: 2026-11-14
- Reference: second implementation by a fresh agent (Python 3.13, standard library), 2026-11-14; licence PSF-2.0
- Tolerance as the file states it: counts, U (a half-integer), thresholds and the points' fractions exact; the AUC relative 1e-15 (absolute 1e-215 below 1e-200); Youden's J absolute 1e-15; statuses, states and codes exact
Apart from the worked example, the cases and their values are not printed here. This shows agreement with this project's recorded cases. It does not show that a method suits your work, and it is not a qualification.
What was not checked
The AUC interval and comparisons of two curves (DeLong 1988, Hanley and McNeil 1982 not read); partial areas; smoothed or parametric curves; the choice of a cut-off, which is never made (no arg-max of Youden's J).
Definition or model
A closed form: the result follows from the inputs by the equations alone.
Equations
Equation 1
at threshold c: TP = #{positives called positive}, FP = #{negatives called positive}, TPR = TP/n₁ (sensitivity), FPR = FP/n₀ (1 − specificity)
called positive when score ≥ c (higher-is-positive) or ≤ c (lower-is-positive), so a positive and a negative whose score equals c are both called positive. The thresholds: first, always, the point (0, 0) with threshold 'above-every-score' (higher-is-positive) or 'below-every-score' (lower-is-positive), nothing called positive
then each distinct score of either group, from the most positive in the stated direction, as c in the scores' unit, −0.0 and 0.0 being one score (served as 0)
the last point is (1, 1)
| Symbol | Meaning and unit |
|---|---|
| n₁ | positives |
| n₀ | negatives |
| c | threshold (in the caller's unit), as-given |
Source: Hajian-Tilaki K. Receiver operating characteristic (ROC) curve analysis for medical diagnostic test evaluation. Caspian J Intern Med 2013;4(2):627-635, section Table 1 (TPF, FPF) and the ROC plot of TPF against FPF across cut-offs; Table 2, version of record, PMC full text (PMC3755824); read in full on 2026-11-17 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning a35ca642b1b1. Free to read (free to read on PMC; © 2013 Caspian Journal of Internal Medicine, no Creative Commons licence stated), checked 2026-11-17. No erratum found (searched Europe PMC: the record's comment and correction list (PMID 24009950)), 2026-11-11.
Equation 2
AUC = U/(n₁n₀), U = Σᵢ Σⱼ ψ(xᵢ, yⱼ), ψ = 1 if the positive's score is more positive, ½ if tied, 0 if less, in the stated direction
| Symbol | Meaning and unit |
|---|---|
| U | Mann–Whitney count: a multiple of ½ from 0 to n₁n₀, counted exactly (2U in integers) and served as a number, a whole number or one ending in .5 when an odd number of pairs tie |
| AUC | area |
| xᵢ | score of positive i (in the caller's unit), as-given |
| yⱼ | score of negative j (in the caller's unit), as-given |
| ψ | 1, ½ or 0 for each pair, as defined in the text |
Source: Hajian-Tilaki K. Receiver operating characteristic (ROC) curve analysis for medical diagnostic test evaluation. Caspian J Intern Med 2013;4(2):627-635, section Indices of Accuracy: the AUC as the probability that a randomly chosen diseased subject is ranked as more likely diseased, by the Mann–Whitney U statistic; the ½ for ties is the trapezoidal area's (the builder's algebra, checked against scikit-learn), version of record, PMC full text (PMC3755824); read in full on 2026-11-17 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning a35ca642b1b1. Free to read (free to read on PMC; © 2013 Caspian Journal of Internal Medicine, no Creative Commons licence stated), checked 2026-11-17. No erratum found (searched Europe PMC: the record's comment and correction list (PMID 24009950)), 2026-11-11.
Equation 3
J = TPR − FPR at each threshold, computed as written
it equals Se + Sp − 1
| Symbol | Meaning and unit |
|---|---|
| J | Youden's index |
Source: Hajian-Tilaki K. Receiver operating characteristic (ROC) curve analysis for medical diagnostic test evaluation. Caspian J Intern Med 2013;4(2):627-635, section Advantage of ROC Curve Analysis and Optimal Cut-off Value, the second method of finding an optimal cut-off: "Youden Index=TPF-FPF= Sensitivity+ Specificity -1"; the source maximises it across cut-offs to choose one, which this method never does: J is reported at each threshold as a description of these data (Drybench ruling, 10 November 2026, names; cases, red line 2), version of record, PMC full text (PMC3755824); read in full on 2026-11-17 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning a35ca642b1b1. Free to read (free to read on PMC; © 2013 Caspian Journal of Internal Medicine, no Creative Commons licence stated), checked 2026-11-17. No erratum found (searched Europe PMC: the record's comment and correction list (PMID 24009950)), 2026-11-11.
Conventions
What each mode computes:
direction = higher-is-positive: A score at or above the threshold is called positive; points run from the highest score down; the AUC is P(positive's score > negative's) + ½ P(tie).direction = lower-is-positive: A score at or below the threshold is called positive; points run from the lowest score up; the AUC is P(positive's score < negative's) + ½ P(tie).
Constants
Constants: none used.
Worked example
Worked example: one case of stats-roc@2.0.1, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.
Inputs
- positives[0] = 0.9
- positives[1] = 0.8
- positives[2] = 0.7
- positives[3] = 0.55
- positives[4] = 0.52
- positives[5] = 0.4
- positives[6] = 0.38
- positives[7] = 0.34
- negatives[0] = 0.6
- negatives[1] = 0.51
- negatives[2] = 0.39
- negatives[3] = 0.33
- negatives[4] = 0.3
- negatives[5] = 0.2
- negatives[6] = 0.1
- direction = higher-is-positive
Steps
- u = 46, from positives, negatives; by equation 2; gives u.
- auc = 0.82142857, from u; by equation 2; gives auc.
Answer
u= 46auc= 0.82142857
Where these values came from: an outside program, scikit-learn; SciPy scikit-learn 1.9.1; scipy 1.18.1; typed scores; scikit-learn 1.9.1 roc_curve(drop_intermediate=False) and roc_auc_score, AUC checked equal to SciPy 1.18.1 mannwhitneyu U/(n1 n0).
At build the tool returned this answer within the tolerance the file states: counts, U (a half-integer), thresholds and the points' fractions exact; the AUC relative 1e-15 (absolute 1e-215 below 1e-200); Youden's J absolute 1e-15; statuses, states and codes exact.
Who worked this case: not recorded.
What it refuses, and its input ranges
MISSING_ARGUMENT(invalid input): positives, negatives or direction not sentTOO_FEW_VALUES(invalid input): positives or negatives emptyTOO_MANY_VALUES(invalid input): more than 500 scores in either groupINVALID_NUMBER(invalid input): a score that is not a finite number, or a subnormal one (not 0 and smaller in magnitude than 2.2250738585072014e-308); −0.0 is accepted, as the same score as 0.0MISSING_UNIT(invalid input): a score without a unitUNITS_DIFFER(invalid input): a score, in either group, whose unit is not written as positives[0]'s is, even an equivalent unit spelled differently (mg/L and ug/mL): no unit is converted; only the kit's spellings of one unit (µg and ug, for one) count as the sameINVALID_OPTION(invalid input): direction other than 'higher-is-positive' or 'lower-is-positive'. The arguments are checked in this order, the first failure answering: an argument not in the schema (UNKNOWN_ARGUMENT); then positives (sent, then its count, then each score from the first: a finite, non-subnormal number with a unit, in positives[0]'s unit); then negatives the same way, its units against positives[0]'s; then direction (sent, then one of its two values)
Changes
No correction is logged for stats-roc@2.0.1.
Tools that use it
Cite this version
The empirical ROC curve and its area (AUC) from scores of declared positives and negatives. Drybench; stats-roc@2.0.1; https://www.drybench.com/methods/m/stats-roc/2.0.1 (accessed [date]).