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

Implement Marginalized RVs #118

Closed
ricardoV94 opened this issue Feb 1, 2022 · 4 comments
Closed

Implement Marginalized RVs #118

ricardoV94 opened this issue Feb 1, 2022 · 4 comments
Labels
duplicate This issue or pull request already exists enhancement New feature or request graph rewriting Involves the implementation of rewrites to Aesara graphs

Comments

@ricardoV94
Copy link
Contributor

ricardoV94 commented Feb 1, 2022

Working in pymc-devs/pymc#5438, I realized that the pattern that we need to match for Marginalized RVs is not too bad:

import aesara.tensor as at
from aeppl import joint_logprob

weights_rv = at.random.dirichlet([1, 1], name="weights")
components = at.stack([at.random.normal(name="c1"), at.random.normal(name="c2")], axis=-1)
mix_rv = at.sum(components * weights_rv, axis=-1)
mix_rv.name = "mix"

# weights can also just be a deterministic, only thing that matters is that it adds up to 1
weights_vv = weights_rv.clone() 
mix_vv = mix_rv.clone()

joint_logprob({weights_rv: weights_vv, mix_rv: mix_vv})
@ricardoV94 ricardoV94 added enhancement New feature or request graph rewriting Involves the implementation of rewrites to Aesara graphs labels Feb 1, 2022
@brandonwillard
Copy link
Member

Don't forget to link to the related issues: #21.

@brandonwillard
Copy link
Member

Actually, that might just be a duplicate.

@brandonwillard brandonwillard added the duplicate This issue or pull request already exists label Feb 1, 2022
@ricardoV94
Copy link
Contributor Author

Actually, that might just be a duplicate.

I think it's slightly different than that issue but I have to think about it a bit more.

@ricardoV94
Copy link
Contributor Author

Nope, this is simply wrong... The original one is indeed what I had in mind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request graph rewriting Involves the implementation of rewrites to Aesara graphs
Projects
None yet
Development

No branches or pull requests

2 participants