Skip to content

Handle broadcasting of parameters in Censored distributions #5703

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

Closed
ricardoV94 opened this issue Apr 8, 2022 · 3 comments · Fixed by #5719
Closed

Handle broadcasting of parameters in Censored distributions #5703

ricardoV94 opened this issue Apr 8, 2022 · 3 comments · Fixed by #5719

Comments

@ricardoV94
Copy link
Member

ricardoV94 commented Apr 8, 2022

When size is not specified, the base distribution is not resized and can broadcast with lower / upper, with repeated draws.

import aesara.tensor as at
import pymc as pm
rng = at.random.default_rng(123)
x = pm.Censored.dist(pm.Normal.dist(0), lower=[-1, -1, -1], upper=[1, 1, 1], rngs=(rng,))
x.eval()  # array([-0.98912135, -0.98912135, -0.98912135])

We need to do something like in:

# If not explicit, size is determined by the shapes of mu, sigma, and init
bcast_shape = at.broadcast_arrays(mu, sigma, init)[0].shape
init = resize_dist(init, bcast_shape)

@ghost
Copy link

ghost commented Apr 9, 2022

Can you please be more specific? What should one to do fix this without changing base code?

@ricardoV94
Copy link
Member Author

What do you mean without changing the base code?

@ricardoV94
Copy link
Member Author

If you just want an immediate workaround, you can just make sure to pass size explicitly:

x = pm.Censored.dist(pm.Normal.dist(0), lower=[-1, -1, -1], upper=[1, 1, 1], size=3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant