[WIP] Allow size argument sampling from Normal distribution#2623
[WIP] Allow size argument sampling from Normal distribution#2623ColCarroll wants to merge 1 commit intopymc-devs:masterfrom
size argument sampling from Normal distribution#2623Conversation
|
The shape handling is a bit of a mess underneath IMO, you are very brave to tackle it ;-) Also, the following works on master: x = pm.Normal.dist(mu=np.array([1, 2]), sd=np.array([.2, .3]), shape=(2,))
x.random(size=5)For the second case: with pm.Model():
pm.Normal('X', mu=np.array([1, 2]), sd=np.array([.2, .3]), shape=(9,2))
trace = pm.sample()Which to me is that in the current setup, user needs to be more discipline and provide the right shape when it is not observed. |
|
Shapes, rearing their ugly head again. After long discussions on this, I think the @ColCarroll Your fix for |
|
Yeah not sure if it is still feasible, but I think having both kwarg of |
|
@ColCarroll i think this is a reasonable fix for a tricky problem, thanks for prototyping it! |
|
I was so naive then. Closed by #2983 |
This came up in #2614, and is a super partial fix that I wanted opinions on before implementing everywhere. Consider the following two code samples:
This returns a
(5,2)array with this change, as (arguably!) desired. On master, it throws an exception (which is the bug in #2614)This returns a
(500, 2)array with this change, ignoring theshape=9argument, which I think is bad. On master, it throws an exception, which I think is good. My understanding is thatshapeis intended to be a hint as to the shape ofmu/sd? It shouldn't be hard to throw an exception with this change (just change the line toself.shape = self.shape or np.broadcast(...).shape).I can add this change pretty easily to all the distributions, but wanted input before proceeding!