-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add Kumaraswamy distribution (#2994) #2998
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
Thanks for the contribution. This looks really good. You have a test for the |
Great! I have added a test for the log PDF. I noticed that the Travis build for this branch was failing due to |
LGTM - could you please add a line to the RELEASE-NOTES? |
Actually, this looks like it fails for A Good Reason, but I can't figure out why. I would guess that it fails whenever
|
To fix the tests, I tried to change the domain of the parameters to exclude 0. Unfortunately, running |
I'm not familiar with the |
pymc3/tests/test_distributions.py
Outdated
@@ -580,6 +581,14 @@ def test_beta(self): | |||
lambda value, alpha, beta: sp.beta.logpdf(value, alpha, beta)) | |||
self.pymc3_matches_scipy(Beta, Unit, {'mu': Unit, 'sd': Rplus}, beta_mu_sd) | |||
|
|||
def test_kumaraswamy(self): | |||
Rpositive = Domain([.01, .1, .9, .99, 1, 1.5, 2, 100, inf]) |
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.
Maybe move this to where other domains are defined?
I would consider using e-5 as first value, and also use this domain for Beta tests.
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.
… actually, the same holds for parameters of gamma, exponential, etc. so changing these tests to use this domain is perhaps better left for a subsequent merge.
@paulkernfeld actually the first and last values of the domain are excluded by default, so it's really the Hence, discard my review. |
Wow! is that why |
Further inspection… this is actually a numerical overflow issue. Computing exp(logmean) works, ie:
|
@gBokiau great insight! I have pushed a patch that computes the mean and variance using more logs. How did you figure out that this was the problem? @ColCarroll I have reverted my change that added |
@paulkernfeld it didn't make sense for it to have infinite mean since its a unit measure, then noticed the gamma functions, esp. w/ reciprocals. Gamma functions are very prone to n.o., Weibull has the same affliction. Domains absolutely need a rewrite (#2966) |
Thanks @paulkernfeld! And congrats on the first PR ;-) |
Please let me know what additional testing you'd like to see for this. It looks like many of the distribution tests compare the PyMC3 implementation to a scipy implementation, but I don't think that scipy.stats implements the Kumaraswamy distribution.
close #2994