-
Notifications
You must be signed in to change notification settings - Fork 409
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
Weird quantile failure for a Gamma distribution #1510
Comments
I checked and the example works with StatsFuns@0.9.15 but errors in the way you describe with StatsFuns@0.9.16. So it seems this bug was introduced by JuliaStats/StatsFuns.jl#113. Looks like a bug in SpecialFunctions at first glance. |
Yes, this is a bug in SpecialFunctions: julia> using SpecialFunctions
julia> gamma_inc_inv(0.010316813105574363, 1-0.010101010101010102, 0.010101010101010102)
ERROR: DomainError with -5.912352019184924:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
Stacktrace:
[1] throw_complex_domainerror(f::Symbol, x::Float64)
@ Base.Math ./math.jl:33
[2] sqrt
@ ./math.jl:567 [inlined]
[3] gamma_inc_inv_qsmall(a::Float64, q::Float64)
@ SpecialFunctions ~/.julia/packages/SpecialFunctions/9pXme/src/gamma_inc.jl:707
[4] __gamma_inc_inv(a::Float64, minpq::Float64, pcase::Bool)
@ SpecialFunctions ~/.julia/packages/SpecialFunctions/9pXme/src/gamma_inc.jl:945
[5] _gamma_inc_inv
@ ~/.julia/packages/SpecialFunctions/9pXme/src/gamma_inc.jl:933 [inlined]
[6] gamma_inc_inv(a::Float64, p::Float64, q::Float64)
@ SpecialFunctions ~/.julia/packages/SpecialFunctions/9pXme/src/gamma_inc.jl:915
[7] top-level scope
@ REPL[12]:1
(jl_j536nH) pkg> st
Status `/tmp/jl_j536nH/Project.toml`
[276daf66] SpecialFunctions v2.1.2 |
I opened an issue in the SpecialFunctions repo: JuliaMath/SpecialFunctions.jl#385 |
Thanks |
So I saw the pull request being made for "SpecialFunctions.jl" and updated all my packages. I'm seeing fewer failures (the previous example now works) but I still ran into a failure here
It looks like we're getting closer here, because the log-domain error is for -9.5893e-320 which may as well be zero for all intents and purposes. |
I was also able to trigger a different kind of error with this:
|
So the last pull request in SpecialFunctions.jl fixed a lot of the earlier issues, but there's still a couple cases where it fails. You mentioned I should pin StatsFuns.jl to version 0.9.15 and not use 0.9.16? I did it on my computer and it worked, but how would I do this inside a Packages.toml file? I'm saying this because I thought Distributions.jl -> Project.toml specified that its version of StatsFuns had to be "0.9.15" (I figured that the convention would be that Distributions.jl wouldn't be compatible with 0.9.16 because StatsFuns.jl is a pre-release). I clearly still have more to learn about Julia's package manager. How would I fix this in my own package so that only StatsFuns "0.9.15" or earlier is used for its Distributions.jl dependency? Use something like this? |
Maybe the Pkg docs are helpful: https://pkgdocs.julialang.org/v1/
You can use
if it should be exactly StatsFuns 0.9.15 (https://pkgdocs.julialang.org/v1/compatibility/#Equality-specifier), and e.g.
if it should be 0.9.13, 0.9.14, or 0.9.15. |
Oh, shoot. I missed Equality specifiers when I was skimming the documentation. Thanks. That makes sense. |
I verified this behavior no longer happens with Distributions.jl v0.25.62 using StatsFuns.jl v1.01. Instead I get a reasonable result
so it's fair to call this issue closed. Thanks for all your work! |
Had a random failure here, normally this sort of things happens when your quantile is greater than 1 but in this case, it's only 0.98989898989899
The text was updated successfully, but these errors were encountered: