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

Math in random does not broadcast well #3508

Closed
lucianopaz opened this issue Jun 6, 2019 · 1 comment
Closed

Math in random does not broadcast well #3508

lucianopaz opened this issue Jun 6, 2019 · 1 comment

Comments

@lucianopaz
Copy link
Contributor

lucianopaz commented Jun 6, 2019

Description of your problem

Same error as #3481 affects Triangular, TruncatedNormal, Rice and ZeroInflatedNegativeBinomial distributions. The problem is caused because there are some math operations that are applied to the results of draw_values. If the distribution parameters come from non scalar RVs, then these results may not broadcast well with each other. A simple fix is to delegate all the broadcasting to generate_samples, and add a _random method that does the required math.

Please provide a minimal, self-contained, and reproducible example.

# For Triangular, but the same patter applies to the other distributions
with pm.Model():
    a = pm.Uniform('a', 0, 1, shape=3) - 1
    b = pm.Uniform('b', 0, 1)
    c = pm.Triangular('c', c=b, lower=a, upper=1, shape=(4, 3))
    pm.sample_prior_predictive(10)

Versions and main components

  • PyMC3 Version: 3.7
  • Theano Version: 1.0.4
  • Python Version: 3.6
  • Operating system: Ubuntu
  • How did you install PyMC3: pip
@lucianopaz
Copy link
Contributor Author

Closed by #3509

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

No branches or pull requests

1 participant