-
-
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
Simplify MvNormal Cholesky decomposition API #3881
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3881 +/- ##
==========================================
- Coverage 90.71% 90.67% -0.04%
==========================================
Files 135 135
Lines 21314 21330 +16
==========================================
+ Hits 19335 19342 +7
- Misses 1979 1988 +9
|
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 we should return the correlation matrix (or possibly the covariance) instead of rho.
For rho it is difficult to figure out what value is which. The correlation / covariance has the naturally correct shape.
Thanks for the thorough review Adrian! |
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.
Found another one, sorry :-)
I think it would be better to not specify the full name of the stds as arguments, but instead a postfix. Default could be std_postifx='_stds'
and corr_postfix='_corr'
. Then the packed name should be {name}_packed__
, the stds {name}_stds
and corr {name}_corr
. If the postix is None, we don't store the variable as deterministic.
That way it matches the pymc3 behavior for transformed variables for the most part.
Mmmh yeah, I think I get what you're saying. That's a good idea. |
A non- |
Just updated the code. While working on it, I realized it doesn't really make sense to let users choose the postfix, since the customizable part should be the name in |
Looks good to me. |
Thanks Adrian! I'll work on updating the relevant notebooks then, so please do not merge yet. |
Actually, I can't update the notebooks until issue #3884 is resolved. EDIT: I found a workaround for the issue -- I'll update the NBs accordingly and push everything on this PR when it's ready 🎉 |
I just updated the notebooks, so this is ready for review, and ready for merge if the review is positive 🎉 Thanks in advance! |
Do you think this is ready for merge? |
Thanks Thomas! I'll get to play with my new toy right now 🍾 |
Thanks to the great advice of @aseyboldt (vielen Dank!), here is a PR to simplify the API for Cholesky decomposition of MvNormal, as detailed here.
LKJCholeskyCov
class, the new behavior, triggered by thecompute_corr
argument, automatically computes and returns the expanded Cholesky matrix, the correlations matrix and the standard deviations. The posterior distributions of those parameters are also automatically returned in the trace. Here is an example:The former behavior, which is still the default for backwards-compatibility, can be recovered with:
LKJCholeskyCov
andMvNormal
.I'm guessing this is not yet the optimal implementation, so I'm avalaible for any changes, and thank you in advance for the reviews 🖖