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
incomplete_beta loses accuracy for tiny a with very negative b #87
incomplete_beta(a, b, z) is accurate for a >= 0.01 at very negative b (tested to 2e-12 for b in [-1100, -5.5] in test_very_negative_b). Below that, accuracy falls as a -> 0.
Relative error against mpmath at 80 digits, from audit 16 of #65:
b
a
error
-100
1e-3
7e-13
-100
1e-4
3e-12
-100
1e-6
2e-10
-100
1e-8
1e-7
-100
1e-12
6e-4
Wrong results at smaller a:
incomplete_beta(1e-20, -100.0, 0.5) is off by a factor of about 2e5.
incomplete_beta(1e-250, -100.0, 0.5) returns about -5e263 for a strictly positive integral.
incomplete_beta(1e-300, -100.0, 0.9) returns -inf; the true value is about 1e300 and representable.
Raising _NEG_B_STEPS to 256, 512 and 1024 leaves the error unchanged, so this is rounding or conditioning in the continued fraction without reflection (_negative_b), not truncation. Positive b is fine at tiny a (b from 5 to 1000, a from 1e-4 to 1e-20, all within 4e-15), and so is the series regime.
This is not a regression: on main the series is wrong at b = -100. The docs and incomplete_beta Notes now state the range as a >= 0.01. The fix needs a formulation of the _negative_b fraction (or a small-a expansion) that does not lose digits as a -> 0.
Activity