-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
refactor kumaraswamy #4706
refactor kumaraswamy #4706
Conversation
Completely optional for this PR but would you be interested in implementing the Gauging from wikipedia it has a very simple form: https://en.m.wikipedia.org/wiki/Kumaraswamy_distribution |
Failing test is unrelated to this PR. Documented in #4661 |
My math is a little bit rusty, but does the following
Because when I check against the following code, it doesn't match.
|
You are missing the first That is |
I totally missed that! 😩 Thank you for clarifying the equation. I should also add the following test to def test_kumaraswamy(self):
...
def scipy_log_cdf(value, a, b):
return np.log1p(-(1 - value ** a) ** b)
self.check_logp(Kumaraswamy, Unit, {"a": Rplus, "b": Rplus}, scipy_log_cdf) |
It should be |
pymc3/distributions/continuous.py
Outdated
------- | ||
TensorVariable | ||
""" | ||
return bound(at.log1p(-((1 - value ** a) ** b)), value >= 0, value <= 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.
Value above one should give a logcdf of 0, so we need a switch: at.switch(value < 1, normal expression, 0)
, and to remove value <= 1
as a bound condition. We should still keep the a > 0
and b > 0
conditions as in the logp
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.
does tt
equal to at
? Because I assume tt
is Theano tensor and it is not available.
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.
Yes of course. It was a mistake, I am still used to writing with theano's abbreviation :p
Fixed the comment
Looks to be on the right track. I left you some comments. In the meantime you can add a release note mentioning the |
The failing test seems to be a precision issue. This means we may want to break the exponent as in your first suggestion. I'll push some changes in a second. |
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.
I think it's ready! Thanks for the PR
Thank you so much! |
* refactor kumaraswamy * add logcdf method Co-authored-by: Farhan Reynaldo <farhanreynaldo@gmail.com> Co-authored-by: Ricardo <ricardo.vieira1994@gmail.com>
This PR closes a subset of #4686, which is Kumaraswamy distribution. But, I am not quite sure why the
check_pymc_draws_match_reference
test failed.