-
Notifications
You must be signed in to change notification settings - Fork 246
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
WIP: Added CDF for gamma, inverse gamma and log normal densities #1250
Conversation
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, @omarfsosa! It is great to have those cdf methods!
numpyro/distributions/continuous.py
Outdated
@@ -447,6 +451,10 @@ def variance(self): | |||
def tree_flatten(self): | |||
return super(TransformedDistribution, self).tree_flatten() | |||
|
|||
def cdf(self, x): | |||
inv_transform = PowerTransform(-1.0).inv | |||
return 1 - self.base_dist.cdf(inv_transform(x)) |
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.
nit: I guess you can use cdf(1 / x)
for simplicity (and a bit faster)
numpyro/distributions/continuous.py
Outdated
@@ -845,6 +853,10 @@ def variance(self): | |||
def tree_flatten(self): | |||
return super(TransformedDistribution, self).tree_flatten() | |||
|
|||
def cdf(self, x): | |||
inv_transform = ExpTransform().inv | |||
return self.base_dist.cdf(inv_transform(x)) |
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.
nit: maybe using cdf(log(x))
for consistency with the above one
Hi @omarfsosa, you might want to merge the fixes in #1251 to unblock your PR. |
Ah thanks, I was wondering what happened there. I'll merge those. |
@omarfsosa There are a couple of failing tests due to numerical issues and a weird failing test for vectorized chain method. But I have addressed them in that PR and it has been merged to master. You might want to merge with |
Hi @omarfsosa, could you merge the master branch? CI is not stable recently. We just added a couple of other fixes for CI. I think after merging, this PR should pass CI. |
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, @omarfsosa !
Just a couple of nice-to-have methods.