Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Mixture distribution for V4 (#5438)
* Set `expand=True` when calling `change_size` in `SymbolicDistribution` * Move NormalMixture tests to their own class * Move mixture random tests from test_distributions_random to test_mixture * Use specific imports in test_mixture * Reenable Mixture tests in pytest workflow * Refactor Mixture distribution Mixtures now use an `OpFromGraph` that encapsulates the Aesara random method. This is used so that logp can be easily dispatched to the distribution without requiring involved pattern matching. The Mixture random and logp methods now fully respect the support dimensionality of its components, whereas previously only the logp method did, leading to inconsistencies between the two methods. In the case where the weights (or size) indicate the need for more draws than what is given by the component distributions, the latter are resized to ensure there are no repeated draws. This refactoring forces Mixture components to be basic RandomVariables, meaning that nested Mixtures or Mixtures of Symbolic distributions (like Censored) are not currently possible. Co-authored-by: Larry Dong <[email protected]> * Add warning when using iterable with single Mixture component * Update Mixture docstrings * Emphasize equivalency between iterable of components and single batched component * Add example with mixture of two distinct distributions * Add example with multivariate components * Refactor NormalMixture * Refactor TestMixtureVsLatent The two tests relied on implicit behavior of V3, where the dimensionality of the weights implied the support dimension of mixture distribution. This, however, led to inconsistent behavior between the random method and the logp, as the latter did not enforce this assumption, and did not distinguish if values were mixed across the implied support dimension. In this refactoring, the support dimensionality of the component variables determines the dimensionality of the mixture distribution, regardless of the weights. This leads to consistent behavior between the random and logp methods as asserted by the new checks. Future work will explore allowing the user to specify an artificial support dimensionality that is higher than the one implied by the component distributions, but this is for now not possible. * Remove MixtureSameFamily Behavior is now implemented in Mixture * Add Mixture moments * Update release notes Co-authored-by: Larry Dong <[email protected]>
- Loading branch information