You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]: stats/base/dists/f/cdf loses accuracy for small x and returns 0 for very small x #16655
The F distribution CDF is inaccurate for small x and returns exactly 0 once d1*x/d2 is below about 1e-16.
For d1*x <= d2, the implementation evaluates betainc( d2/(d2+(d1*x)), d2/2, d1/2, true, true ). The first argument is 1 - d1*x/(d2+d1*x), which loses most of its significant digits when x is small (and rounds to exactly 1 for tiny x), so the upper regularized incomplete beta is computed from a heavily rounded input.
The branches appear to be swapped relative to the numerically stable choice (also used by Boost's fisher_f CDF): when d1*x <= d2, compute betainc( (d1*x)/(d2+(d1*x)), d1/2, d2/2, true, false ) (small argument, no cancellation), and when d1*x > d2, compute betainc( d2/(d2+(d1*x)), d2/2, d1/2, true, true ).
With the branches swapped, the maximum relative error over a grid of d1, d2 in {0.5, 1, 2, 3, 5, 10, 30} and x from 1e-20 to 1e8 drops from 1.0 to about 1.6e-15 (compared with SciPy and mpmath).
The same logic is in lib/main.js, lib/factory.js, and src/main.c.
Related Issues
None
Questions
No.
Demo
N/A
Reproduction
var cdf = require( '@stdlib/stats/base/dists/f/cdf' );
And thank you for opening your first issue! We will get back to you shortly. 🏃 💨
If you have any further questions while waiting for a response, please join our Zulip community to chat with project maintainers and other community members.
changed the title [-]stats/base/dists/f/cdf loses accuracy for small x and returns 0 for very small x[/-][+][BUG]: stats/base/dists/f/cdf loses accuracy for small x and returns 0 for very small x[/+]on Nov 16, 2026
changed the title [-][BUG]: stats/base/dists/f/cdf loses accuracy for small x and returns 0 for very small x[/-][+][BUG]: `stats/base/dists/f/cdf` loses accuracy for small x and returns 0 for very small x[/+]on Nov 16, 2026
Activity
stdlib-bot commentedon Nov 16, 2026
👋 Hi there! 👋
And thank you for opening your first issue! We will get back to you shortly. 🏃 💨
If you have any further questions while waiting for a response, please join our Zulip community to chat with project maintainers and other community members.
[-]stats/base/dists/f/cdf loses accuracy for small x and returns 0 for very small x[/-][+][BUG]: stats/base/dists/f/cdf loses accuracy for small x and returns 0 for very small x[/+][-][BUG]: stats/base/dists/f/cdf loses accuracy for small x and returns 0 for very small x[/-][+][BUG]: `stats/base/dists/f/cdf` loses accuracy for small x and returns 0 for very small x[/+]