-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add DensityDist moment #5159
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 DensityDist moment #5159
Conversation
1cd6d46
to
f83c556
Compare
This won't work for multivariate distributions... Should we raise a NotImplementedError in those cases. We can inspect the RV to know the number of dimensions. Also we should port these tests to the present module: https://github.com/pymc-devs/pymc/blob/main/pymc/tests/test_moment.py ? |
Codecov Report
@@ Coverage Diff @@
## main #5159 +/- ##
==========================================
+ Coverage 78.10% 78.11% +0.01%
==========================================
Files 88 88
Lines 14161 14168 +7
==========================================
+ Hits 11060 11067 +7
Misses 3101 3101
|
I hadn’t thought of that. How can we know the shape of the support dimensions? We could potentially return a tensor with the support dimensions as broadcastable. Would that then be broadcasted correctly at the later sampling stage?
Yes, and maybe also remove that module entirely |
By the way, this should be very similar to what we’ll want to do for the Simulator distribution, so once we agree on how we handle multivariate distributions, I can port it to the simulator |
We can access We can also just return something like
Sounds good. |
Yeah I think so too. My only question is whether for the Simulator a draw from the random function may actually be the preferred starting point. We haven't really explored how well Simulators behave in non SMC samplers... In SMC it doesn't matter because we always start sampling form the prior and not from moments. @aloctavodia any opinion on this? |
@ricardoV94, I wrote a very small fallback option that uses the size of a random draw to inform the size of the moment, in the case of multivariate |
Sounds good. I'll check later more carefully for any bugs/issues but you can rebase in the meantime. |
a5571ff
to
a9f578f
Compare
4d7e14d
to
edb6f70
Compare
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.
Looks great @lucianopaz, just need to resolve the conflicts with the main branch
Damn, I can't keep up with all the merged PRs |
edb6f70
to
c1f0540
Compare
c1f0540
to
45e33bc
Compare
Thanks @lucianopaz! |
* Add DensityDist moment * Specialize get_moment for multivariate density dists
Adds a default moment of 0 for the
DensityDist
distribution. This allows theDensityDist
to be used bypm.sample
even if the users don't explicitly pass aget_moment
function to it.This PR contributes to #5078