-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
MAINT: stats.rv_discrete.pmf: should be zero at non-integer argument #17166
Conversation
LGTM! Shall we merge it as is, or is there anything you're adding here still? |
All set, if the last commit looks safe enough to you. |
LGTM, let's roll with it. Merged, thanks Matt |
This has a defect label and the two commits can apparently be cleanly cherry-picked to |
Good thing to backport. Thanks! |
my guess is that this is too restrictive AFAIU: It might not cause problems for statsmodels because we use our own implementation of logpdf/loglike for (quasi-)poisson for estimation. |
For types other than |
I have been using this "feature" here just as a "trick" for plotting (the dots are evaluated at integers values and the dashed line for floats). I also have being using this "feature " for a project where I approximate discrete variables (actually their pmf) as continuous. I understand that the pmf should be zero at non-integer argument and thus this should be the default behaviour. But I will really appreciate an argument to allow results for non-integer values. Is that possible? |
The behavior that you plot is not intentional, just an accident that the formulae used to compute the integral-input PMFs happen to also be evaluatable on non-integer values. It doesn't necessarily have any particular properties that would make it suitable for approximating PMFs as PDFs or for plots. |
Thanks for the feedback. In those visualizations the dashed line is used just as visual aid, knowing thatthe dots are the actual values of the pmf. They seem to work reasonable well in practice, at least so far. There has been some previous interest on evaluating the pmf at non-integers values like this paper https://arxiv.org/abs/2102.04509. |
What's required in that paper are particular continuous extensions of certain ways to formulate the discrete PMFs. I'm pretty sure that we don't want to take on the burden to guarantee those. It's quite a niche use case, and would likely involve tradeoffs with the main use case. |
Reference issue
gh-17146
gh-15932
What does this implement/fix?
There was a report in gh-17146 that
rv_discrete.pmf
does not return 0 at non-integer arguments as it used to. This was broken because a line in gh-15932 was out of the intended order. This fixes the order and adds tests.