Skip to content
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

logpdf(Binomial(0,0), x=0) returns NaN instead of 0 when x is Int32 or lower #1397

Closed
BenjamenSimon opened this issue Sep 28, 2021 · 5 comments

Comments

@BenjamenSimon
Copy link

BenjamenSimon commented Sep 28, 2021

logpdf(Binomial(0, 0.), 0) # = 0.00

logpdf(Binomial(0, 0.), 0.) # = 0.00

logpdf(Binomial(0, 0.), Int32(0)) # = NaN

logpdf(Binomial(0, 0.), Int16(0)) # = NaN

logpdf(Binomial(0, 0.), Float32(0)) # = NaN

logpdf(Binomial(0, 0.), Float16(0)) # = NaN
@andreasnoack
Copy link
Member

I believe this will be fixed by JuliaStats/StatsFuns.jl#113. Binomial(0, 0.) is a really odd distribution, though.

@devmotion
Copy link
Member

This is also fixed by JuliaStats/StatsFuns.jl#125 (BTW would be great if you can find time for a review @andreasnoack - otherwise, if you are busy maybe someone else could review it?):

julia> logpdf(Binomial(0, 0.), 0) # = 0.00
0.0

julia> logpdf(Binomial(0, 0.), 0.) # = 0.00
0.0

julia> logpdf(Binomial(0, 0.), Int32(0)) # = NaN
0.0

julia> logpdf(Binomial(0, 0.), Int16(0)) # = NaN
0.0

julia> logpdf(Binomial(0, 0.), Float32(0)) # = NaN
0.0

julia> logpdf(Binomial(0, 0.), Float16(0)) # = NaN
0.0

@BenjamenSimon
Copy link
Author

BenjamenSimon commented Sep 28, 2021

Thank you both. Do you have a timeline of when those will be implemented/fixed?

For context, its one term in the likelihood of a chain-binomial simulation. So it represents the probability that no events occur when there are no events that can occur (which is 1) which is a valid situation in the model of interest.

@devmotion
Copy link
Member

As a temporary workaround you can install JuliaStats/StatsFuns.jl#125 manually by running

] add StatsFuns#dw/rmath_real+julia_logpdf

in the Julia REPL. Unfortunately, the PR is missing a more detailed review (should work fine though) and it is difficult to estimate when it will be approved, merged, and released.

@devmotion
Copy link
Member

The issue will be fixed in StatsFuns 0.9.11 which will be available when JuliaRegistries/General#45672 is merged. Once it is available you should revert the manual installation suggested in the last comment (run ] free StatsFuns in the Julia REPL) and install the latest version of StatsFuns (e.g. by running ] up).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants