-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix for #3310 and some more #3319
Conversation
…ps broadcasting multiple rvs calls with different size and distribution parameter shapes. Added shape guards to other continuous distributions.
…t a parameter shape aware size input thanks to generate_samples.
RELEASE-NOTES.md
Outdated
@@ -36,6 +36,8 @@ This will be the last release to support Python 2. | |||
- Fixed `Rice` distribution, which inconsistently mixed two parametrizations (#3286). | |||
- `Rice` distribution now accepts multiple parameters and observations and is usable with NUTS (#3289). | |||
- `sample_posterior_predictive` no longer calls `draw_values` to initialize the shape of the ppc trace. This called could lead to `ValueError`'s when sampling the ppc from a model with `Flat` or `HalfFlat` prior distributions (Fix issue #3294). | |||
- Added the `broadcast_distribution_samples` function that helps broadcasting arrays of drawn samples, taking into account the requested `size` and the inferred distribution shape. This sometimes is needed by distributions that call several `rvs` separately within their `random` method, such as the `ZeroInflatedPoisson` (Fix issue #3310). |
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.
Should be under the new release note (v3.6)
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 created a new note for 3.7.
pymc3/distributions/continuous.py
Outdated
@@ -964,6 +965,11 @@ def random(self, point=None, size=None): | |||
""" | |||
mu, lam, alpha = draw_values([self.mu, self.lam, self.alpha], | |||
point=point, size=size) | |||
print(mu.shape, lam.shape, alpha.shape) |
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.
dont forget to remove the print
Thanks! |
Added
broadcast_distribution_samples
, which helps broadcasting multiple rvs calls with differentsize
and distribution parameter shapes. Added shape guards to other continuous distributions. In particular, this fixes #3310, but it also prevents similar things from happening in other discrete and continuous distributions that could encounter the same pathological behavior.