-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Binomial and Poisson Moment #5150
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
Binomial and Poisson Moment #5150
Conversation
7dc703a
to
cd9f9d1
Compare
Codecov Report
@@ Coverage Diff @@
## main #5150 +/- ##
==========================================
+ Coverage 77.86% 77.92% +0.06%
==========================================
Files 88 88
Lines 14165 14109 -56
==========================================
- Hits 11029 10995 -34
+ Misses 3136 3114 -22
|
@farhanreynaldo Need to resolve conflicts. |
This is my first time having a conflict. Are the following steps correct?
and then accept both changes and push the resolved conflicts?
|
I think during rebasing you just git add, and then you force push. |
pymc/distributions/discrete.py
Outdated
@@ -570,6 +576,11 @@ def dist(cls, mu, *args, **kwargs): | |||
# mode = intX(at.floor(mu)) |
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.
Seems like we have a leftover from before. Do you mind removing the commented out code?
# mode = intX(at.floor(mu)) |
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.
Also note that we used the floor of mu, we should do the same in the new get_moment
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.
Is the IntX
necessary or should I just include the at.floor
?
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.
Not needed either I think
pymc/distributions/discrete.py
Outdated
@@ -117,6 +117,12 @@ def dist(cls, n, p, *args, **kwargs): | |||
# mode = at.cast(tround(n * p), self.dtype) |
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.
# mode = at.cast(tround(n * p), self.dtype) |
Same here, we should remove the old commented out code, and use at.round
in the new get_moment
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.
Is the at.cast
also necessary here?
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.
Not anymore. That's done automatically by the function that calls get_moment
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.
Left a couple of suggestions @farhanreynaldo. Thanks for the 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.
Some suggestions to make the tests more robust
(np.arange(1, 5), (2, 4), np.full((2, 4), np.arange(1, 5))), | ||
], | ||
) | ||
def test_poisson_moment(mu, size, expected): |
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.
Some of the test combinations should include non integer values for mu to check the flooring is working as expected
(10, np.arange(1, 6) / 10, (2, 5), np.full((2, 5), np.arange(1, 6))), | ||
], | ||
) | ||
def test_binomial_moment(n, p, size, expected): |
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.
Some of the test combinations should have a n*p
that is different when rounded and not rounded to make sure it is working as expected
Add moments and tests for the below distributions as part of #5078: