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

Inconsistent behavior of random for singleton RVs and draw sizes #4206

Closed
lucianopaz opened this issue Nov 1, 2020 · 2 comments
Closed

Inconsistent behavior of random for singleton RVs and draw sizes #4206

lucianopaz opened this issue Nov 1, 2020 · 2 comments
Milestone

Comments

@lucianopaz
Copy link
Contributor

lucianopaz commented Nov 1, 2020

Description of your problem

This issue summarizes two inconsistent behaviors of pymc3's random method. One happens for distributions that are declared with shape (1,). The other happens when a distribution's random method is called with size=1.

Singleton array distributions

>>> import pymc3 as pm
>>> pm.Normal.dist(0, 1, shape=1).random().shape
()
>>> pm.Normal.dist(0, 1, shape=1).random(size=10).shape
(10,)

These two calls should output shapes (1,) and (10, 1) respectively. The singleton distribution dimension is incorrectly reduced.

Random draws of a single value

>>> import pymc3 as pm
>>> pm.Normal.dist(0, 1).random(size=1).shape
()
>>> pm.Normal.dist(0, 1, shape=1).random(size=1).shape
()
>>> pm.Normal.dist(0, 1, shape=10).random(size=1).shape
(10,)

These calls should output (1,), (1, 1) and (1, 10) respectively, but the single draw is incorrectly reduced. In particular, this behavior should only happen when we supply size=None or size=().

Versions and main components

  • PyMC3 Version: 3.9.3
  • Theano Version: 1.0.5
  • Python Version: 3.7.6
  • Operating system: Ubuntu
  • How did you install PyMC3: (conda/pip) pip
@AlexAndorra
Copy link
Contributor

@Sayam753, can we close this now that #4207 has been merged? Actually, can we close all the issues you mention in the PR's description?

@Sayam753
Copy link
Member

Hi @AlexAndorra
This issue has been fixed by Michael is his #4214 PR. So, lets ping @michaelosthege to ask for closing this issue.
Coming to #4207, all the issues mention in the PR's description have been resolved. I think @twiecki closed them all.

@twiecki twiecki closed this as completed Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants