Add rewrite for Mixture when `comp_dists` can be "fused"
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 9.8k
- Forks
- 2.3k
- Avg merge
- 21h 39m
- Merged PRs (30d)
- 5
Description
Description
The following distributions are equivalent:
import pymc as pm
pm.Mixture.dist(w=[0.5, 0.5], comp_dists=[pm.Normal.dist(-1), pm.Normal.dist(1)])
pm.Mixture.dist(w=[0.5, 0.5], comp_dists=pm.Normal.dist([-1, 1]))
But the second one is more efficient, because the logp is vectorized among a single batched Normal.
We could add a rewrite in the logprob_rewrites to convert the former to the second, so that users are not penalized from using the first form (which may be more intuitive for some).
Actually that sort of rewrite stack([rv1, rv2]) -> rv3 could be useful in many places in the logprob submodule
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the logprob_rewrites and logprob submodule, using the two Mixture.dist examples as the behavioral reference. Determine how a list of component distributions can be recognized as equivalent to one batched distribution. Done means the separate-component form receives the same vectorized logp behavior as the fused form, with coverage for the demonstrated Normal case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100