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

Add the transformation between the inverse gamma and the exponential distributions #67

Merged
merged 1 commit into from
Oct 18, 2022

Conversation

rlouf
Copy link
Member

@rlouf rlouf commented Sep 26, 2022

Moves us closer to being able to rewrite the Gibbs sampler for the Horseshoe prior #64. Once this PR and #66 are merged it will be a good time to cross the finish line with aesara-devs/aesara#1036 and refactor the library so relations work both ways #43 before going into automatic rewrites.

@codecov
Copy link

codecov bot commented Sep 26, 2022

Codecov Report

Base: 97.35% // Head: 97.38% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (04590da) compared to base (5b5ae2f).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #67      +/-   ##
==========================================
+ Coverage   97.35%   97.38%   +0.03%     
==========================================
  Files           9        9              
  Lines         606      613       +7     
  Branches       63       60       -3     
==========================================
+ Hits          590      597       +7     
  Misses          5        5              
  Partials       11       11              
Impacted Files Coverage Δ
aemcmc/transforms.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines 61 to 62
assert isinstance(res.owner.op, type(at.true_div))
assert isinstance(res.owner.inputs[1].owner.op, type(at.random.exponential))
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little concerned about the "longevity" of this approach (i.e. the use of type(...)), because it's always possible that at.true_div and/or at.random.exponential could be changed from Op instances to helper functions at any point in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that many of the tests here are lacking. Since we know the moment of the HalfCauchy, and forward sampling is fast, we can check that the mixture gets the first two moments right.

Copy link
Member

Choose a reason for hiding this comment

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

Those checks are fine; it's the approach to performing them that I'm concerned about.

Copy link
Member Author

@rlouf rlouf Oct 4, 2022

Choose a reason for hiding this comment

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

The only other thing I can think of is implement the equivalent exponential model and check that the structures are similar. Is that what you had in mind? I modified the test in this direction.

Copy link
Member

Choose a reason for hiding this comment

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

The only other thing I can think of is implement the equivalent exponential model and check that the structures are similar. Is that what you had in mind? I modified the test in this direction.

That's generally better, but, to alleviate my concern, one only needs to import ExponentialRV and use that instead of type(at.random.exponential).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. I ended up implementing the equivalent exponential model and checking that the structures are similar. This is ready for review.

@rlouf rlouf merged commit ed60d94 into aesara-devs:main Oct 18, 2022
@rlouf rlouf deleted the relation-invgamma-exp branch October 18, 2022 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants