Published

A SciPy exact Wilcoxon p-value error, fixed upstream

SciPy’s exact Wilcoxon path could return zero for a positive p-value. SciPy diagnosed the cause and merged a fix the same day it was reported.

Current status

We reported scipy.stats.wilcoxon(method='exact') issue #26026 on August 25, 2026. SciPy diagnosed the cause, opened pull request #26027, and merged the fix later the same day. Issue #26026 is now closed as completed.

SciPy contributor mdhaber authored the correction. Maintainerj-bowhay approved it and merged commit 6dbd21a into SciPy’s main branch. This page does not claim that a released SciPy version contains the correction yet.

What we observed

On inputs with no ties and no zeros, SciPy documents method='exact' as the exact Wilcoxon signed-rank path. During numerical auditing, we found 105 calls for which the returned p-value did not match the correctly rounded value from an exact rational oracle.

In the representative case reported upstream, SciPy returned 0.0 even though the exact two-sided p-value is approximately 8.12511917099255e-17. A strictly positive probability was therefore lost completely rather than merely rounded by a few floating-point steps.

What SciPy changed

SciPy traced the problem to the survival-function calculation for the Wilcoxon null distribution: the implementation was selecting the wrong tail in one branch. Pull request #26027 corrected that tail-choice condition.

SciPy also added the representative 100-element input vector from #26026 and its exact reference value as a regression test. The full set of 105 affected cases was not added to SciPy’s test suite; we used that larger public dataset separately to check the patch.

How we checked the fix

Before the pull request was merged, we applied the one-line change to a SciPy 1.17.1 installation and reran all 105 oracle cases attached to the issue. The cases that had returned 0.0 were resolved.

After the patch, 75 of 105 cases returned the correctly rounded binary64 value. The remaining 30 were all within 1.25 ulp — roughly 1.25 representable floating-point steps — of the exact reference. The representative reproducer returned 8.12511917099255e-17, matching the regression-test reference.

Scope

Issue #26026 concerns the tie-free, zero-free exact path and the numerical accuracy of its p-values. It does not show that every Wilcoxon calculation in SciPy is affected, and it does not characterize how often ordinary research workflows reach the reported cases.

We found these cases during a broader numerical audit of statistical-test implementations. This page is limited to the public SciPy issue, its upstream fix, and our public validation of that fix; it does not present the broader study’s measurement design or unpublished findings.

Public evidence