Skip to content
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

Merged
merged 6 commits into from
Dec 13, 2021

Conversation

omarfsosa
Copy link
Contributor

Just a couple of nice-to-have methods.

Copy link
Member

@fehiepsi fehiepsi left a 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!

@@ -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))
Copy link
Member

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)

@@ -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))
Copy link
Member

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

@fehiepsi
Copy link
Member

Hi @omarfsosa, you might want to merge the fixes in #1251 to unblock your PR.

@omarfsosa
Copy link
Contributor Author

Ah thanks, I was wondering what happened there. I'll merge those.
Thanks for the suggestions too, I'll fix that and update my PR.

@omarfsosa omarfsosa changed the title Added CDF for gamma, inverse gamma and log normal densities WIP: Added CDF for gamma, inverse gamma and log normal densities Dec 11, 2021
@fehiepsi
Copy link
Member

@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 master branch to get the tests to pass.

@fehiepsi
Copy link
Member

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.

Copy link
Member

@fehiepsi fehiepsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @omarfsosa !

@fehiepsi fehiepsi merged commit 7c8dd4e into pyro-ppl:master Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants