-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Correcting that p should be in [0,1] for a variety of discrete distns. #12962
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
Conversation
…ts/_discrete_distns.py for issue scipy#12952
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @WillTirone. I requested a few changes inline.
scipy/stats/_discrete_distns.py
Outdated
f(k) = \binom{k+n-1}{n-1} p^n (1-p)^k | ||
for :math:`k \ge 0`. | ||
for :math:`k \ge 0`, :math:'0 \leq p \leq 1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strict inequality on the low end:
for :math:`k \ge 0`, :math:'0 \leq p \leq 1' | |
for :math:`k \ge 0`, :math:`0 < p \leq 1` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this requires a strict inequality, should the _argcheck
also include the strict inequality? for nbinom_gen
it is as follows:
def _argcheck(self, n, p):
return (n > 0) & (p >= 0) & (p <= 1)
I guess if so that would be part of a different commit to address that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, that should be (p > 0)
(likewise for geom
). If you are interested, you can make those changes in this PR, or we can do that in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll just add that to this one - that seems simple enough to include.
scipy/stats/_discrete_distns.py
Outdated
f(k) = (1-p)^{k-1} p | ||
for :math:`k \ge 1`. | ||
for :math:`k \ge 1`, :math:'0 \leq p \leq 1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strict inequality on the low end:
for :math:`k \ge 1`, :math:'0 \leq p \leq 1' | |
for :math:`k \ge 1`, :math:`0 < p \leq 1` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also has the same _argcheck
as negative binomial:
def _argcheck(self, p):
return (p <= 1) & (p >= 0)
Instructions for building the docs are in Once you've submitted a PR, you can view the rendered docs online by clicking on the |
Awesome, thank you. I'll check that out. |
… on nbin and geom distributions
Thanks @WillTirone, the updates look good. I'll merge once the last tests finish. |
Thanks for your help @WarrenWeckesser ! |
why is there an asymmetry now in whether boundary points are included? p=0 and p=1 should in most cases be treated the same.
|
PRs with changes in code should be clearly labeled as such if p=0 is a bug, then it should be a bug fix PR e.g #12916 (comment) adding |
I don't see why that should be true in general. Whether or not the end point is a well-defined probability distribution depends on the properties of the distribution. For |
OK, I added the "defect" tag to this PR. |
DOC: adding that p in [0,1] for several discrete distributions in stats/_discrete_distns.py for issue #12952
Reference issue
Closes: #12952
What does this implement/fix?
Since p is a probability, and probabilities must be 0 <= p <= 1, I've added this for the relevant discrete distributions.
Additional information
Thanks!