-
Notifications
You must be signed in to change notification settings - Fork 251
Description
When ibeta) will throw an error because the series expansion doesn't converge. This was first found in scipy/scipy#24566
typedef double T;
T a = 3.1622776601699636e+16;
T b = 3.130654883566682e+18;
T x = 0.010000000000005001;
std::cout << boost::math::ibeta(a, b, x + 1e-12) << std::endl; // 0.50713
std::cout << boost::math::ibeta(a, b, x - 1e-12) << std::endl; // 0.49287
// Error in function boost::math::ibeta: Series evaluation exceeded 1000000 iterations, giving up now.
std::cout << std::setprecision(64) << boost::math::ibeta(a, b, x + 1e-13)<< std::endl;
return 0;The issue is with continued fraction in here. I've tried using the erf asymptotic expansion here, but it gave horrible results.
I came up with a tentative solution in Python that is somewhat accurate, but it feels quite hacky. In the asymptotic expansion above (here), it solves for
where
This taylor approximation actually works fairly well for the example above. When more terms are include in the continued fraction, it seems to be converging to the result in the function ibeta_large_ab with the taylor approximation for
I only see two issues in regards to using the taylor expansion for ibeta than using the entire equation for