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

Logcdf methods of several distributions do not check for invalid parameters #4399

Closed
ricardoV94 opened this issue Jan 2, 2021 · 2 comments · Fixed by #4421
Closed

Logcdf methods of several distributions do not check for invalid parameters #4399

ricardoV94 opened this issue Jan 2, 2021 · 2 comments · Fixed by #4421

Comments

@ricardoV94
Copy link
Member

In working in #4393 and #4387 I realized that several logcdf methods for continuous distributions do not adequately check for invalid parameters and can return either nan or wrong results. If there is an interest, I am willing to do a new PR to fix those as well as to extend the check_logcdf to automatically test that -inf is returned for invalid parameters (i.e., outside the supported range).

Here are some currently failing examples:

pm.Normal.dist(sigma=-1).logcdf(1).eval()  # returns -1.841
pm.Pareto.dist(alpha=1, m=-1).logcdf(1).eval()  # returns 0.693
pm.Weibull.dist(alpha=-1, beta=1).logcdf(1).eval()  # returns -0.459
pm.Cauchy.dist(alpha=0, beta=-1).logcdf(1).eval()  # returns -1.386

pm.Exponential.dist(lam=-1).logcdf(1).eval()  # returns nan
pm.HalfCauchy.dist(beta=-1).logcdf(1).eval()  # returns nan

This and the changes included in #4393 could also be used in check_logp to test that the logp is also correctly handling invalid values / parameters. I would be surprised to find issues in current implementations, given that every logp return seems to be wrapped in bound, but it could still be helpful for people developing new distributions or refactoring old ones...

@twiecki
Copy link
Member

twiecki commented Jan 2, 2021

Want to do a PR?

@ricardoV94
Copy link
Member Author

Want to do a PR?

Yes

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

Successfully merging a pull request may close this issue.

2 participants