-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gamma_inc_inv
throws an DomainError for valid arguments
#385
Comments
The problem is that the expression inside the SpecialFunctions.jl/src/gamma_inc.jl Line 707 in 8b4aba0
a >= 0 and 0 <= q <= 1 , AFAICT it is non-negative iff q < exp(a * (log(a) - 1)) / gamma(a) . It seems in general this is not implied by the condition in SpecialFunctions.jl/src/gamma_inc.jl Line 944 in 8b4aba0
|
I've just tried the original Fortran version accompanying the paper on which our implementation is based and it also fails for this input. From a first read of the paper, it wasn't obvious where |
I had a quick look at the Fortran code and the paper as well yesterday. I assumed it would error since I couldn't spot an obvious difference from our implementation but didn't check it. It wasn't immediately clear to me either from skimming through the paper why it fails and what's the explanation for the if condition. There was a note in the zip file with the Fortran code about a more recent paper with an improved (?) code - maybe the problem is fixed there? |
Just to help track down when things started to go off the rails, the input that triggered all this was from Distributions.jl. I recently updated and some previously smooth code started failing. Before updating yesterday, things ran quite smoothly. In fact, I was able to verify this by running the same code on a different machine that I haven't updated yet. Distributions v0.25.35 (an older version that works):
However, on the same machine, I have a version of SpecialFunctions which fails for the inputs SpecialFunctions v1.8.1:
|
Thanks, this will be fixed soon. There's already a PR to SpecialFunctions with a fix. It's not an issue with Distributions but with SpecialFunctions (therefore I opened the issue here after I was notified about it in an issue in Distributions). You don't see it in the computer where you haven't updated your packages because it means you haven't updated StatsFuns: In StatsFuns 0.9.16 many (inv)(log)cdf functions that used Rmath up until StatsFuns 0.9.15 were replaced with native Julia implementations. And this uncovered the bug here in SpecialFunctions. Currently the example will work with any version of Distributions if you use StatsFuns 0.9.15 but fail if you use 0.9.16. |
Ah okay, well when that's up and running, the solution I'm building will put it to a very thorough test. I make thousands of calls to Normal and Gamma quantiles to assess scale for quadrature. I could probably do some guesswork to capture feasible ranges but quantiles make for a very clean and stable solution. |
First observed in JuliaStats/Distributions.jl#1510:
The same error occurs also in SpecialFunctions 2.0.0, so it wasn't introduced by #377.
The text was updated successfully, but these errors were encountered: