-
Notifications
You must be signed in to change notification settings - Fork 40
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
Numerical instability in student t distribution #165
Comments
I've transfered this issue to StatsFuns since the issue is in StatsFuns.jl/src/distrs/fdist.jl Lines 21 to 29 in 5e866ba
ff = Symbol("fdist"*f)
bf = Symbol("beta"*f)
cf = Symbol("chisq"*f)
@eval function $ff(ν1::T, ν2::T, y::T) where {T<:Real}
if ν2 > some_large_value
return $cf(ν1, y)/ν1
else
x = $bf(ν1/2, ν2/2, y)
return x/(1 - x)*ν2/ν1
end
end |
Thanks for your response! Your answer indeed fixes the issue for the quantile function. However, there a remaining numerical instabilities for other functions of the student t distribution. For example here in line 7, we should switch with high value of the degrees of freedom (lower than infinity) to the normal distribution, this fixes the issue with the log pdf that I have also showed above: StatsFuns.jl/src/distrs/tdist.jl Lines 6 to 10 in 5e866ba
Should I address all this in one PR and use the same threshold value? Should I write a comment in the code why we use a threshold value to switch to the normal/chi^2 distribution? I will test it a bit to get a good threshold value. I am happy to prepare a PR. I haven't done it often, but I will try and will be happy to get feedback. |
Great. You can do it in one or two PRs. Either is fine. Adding a comment is almost always a good idea. |
Hello,
thanks for creating the Distributions.jl package. I used the Student t distribution in a likelihood function and I noticed some numerical instability for large values of the degrees of freedom. I am not sure if this is expected behaviour.
Best,
Felix
The text was updated successfully, but these errors were encountered: