Hi! I am very new to PyMC and probabilistic programming in general, so I wonder if the problem I am having is with me or with PyMC. I have the following model implemented with PyMC 3.5 (distilled from a larger example):
import pymc3 as pm
import numpy as np
with pm.Model() as tmpm:
pri = pm.Dirichlet('pri', a=np.array([10.5, 5.5, 0.5]), shape=(3,))
tmp = pm.Multinomial('tmp', n=100, p=pri, shape=(3,))
b = pm.Beta('b', tmp[0], tmp[1])
I can now do b.random(size=1)
, and that seems to be working fine, sampling a single value of reasonable magnitude. However, if I try b.random(size=10)
, I get:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-66-a308db443d2f> in <module>()
4 b = pm.Beta('b', tmp[0], tmp[1])
5
----> 6 b.random(size=10)
/data/01/dm/conda_envs/spark_py35/lib/python3.5/site-packages/pymc3/model.py in __call__(self, *args, **kwargs)
40
41 def __call__(self, *args, **kwargs):
---> 42 return getattr(self.obj, self.method_name)(*args, **kwargs)
43
44
/data/01/dm/conda_envs/spark_py35/lib/python3.5/site-packages/pymc3/distributions/continuous.py in random(self, point, size)
1073 return generate_samples(stats.beta.rvs, alpha, beta,
1074 dist_shape=self.shape,
-> 1075 size=size)
1076
1077 def logp(self, value):
/data/01/dm/conda_envs/spark_py35/lib/python3.5/site-packages/pymc3/distributions/distribution.py in generate_samples(generator, *args, **kwargs)
522 dist_shape: {dist_shape}
523 broadcast_shape: {broadcast_shape}
--> 524 '''.format(size=size, dist_shape=dist_shape, broadcast_shape=broadcast_shape))
525
526 # reshape samples here
TypeError: Attempted to generate values with incompatible shapes:
size: 10
dist_shape: ()
broadcast_shape: (3,)
Am I doing something wrong, or is it an issue with PyMC?