-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
Passing a tuple (rather than a NumPy array) to a stochastic as the observed
value results in a TypeError. We should be able to pass lists and tuples of data.
Here is an example:
from pymc import Model, Normal, Uniform, sample, NUTS, Deterministic
post_op_stool = 0.19,0.24,0.29,0.32,0.44,0.44
stoma_output = 0.33,0.36,0.42,0.44,0.44,0.49,0.52
tissue_adherent = 0.5,0.52
with Model() as model:
sigma = Uniform('sigma', 0, 100)
tau = Deterministic('tau', sigma ** -2)
mu_po = Normal('mu_po', 0, 0.001)
mu_so = Normal('mu_so', 0, 0.001)
mu_ta = Normal('mu_ta', 0, 0.001)
y_po = Normal('y_po', mu_po, tau, observed=post_op_stool)
y_so = Normal('y_so', mu_so, tau, observed=stoma_output)
y_ta = Normal('y_ta', mu_ta, tau, observed=tissue_adherent)
diff_so_po = Deterministic('diff_so_po', mu_so - mu_po)
diff_ta_po = Deterministic('diff_ta_po', mu_ta - mu_po)
Results in:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-31-82417f5a4deb> in <module>()
14 mu_ta = Normal('mu_ta', 0, 0.001)
15
---> 16 y_po = Normal('y_po', mu_po, tau, observed=post_op_stool)
17 y_so = Normal('y_so', mu_so, tau, observed=stoma_output)
18 y_ta = Normal('y_ta', mu_ta, tau, observed=tissue_adherent)
/Users/fonnescj/Code/pymc/pymc/distributions/distribution.pyc in __new__(cls, name, *args, **kwargs)
17 data = kwargs.pop('observed', None)
18 dist = cls.dist(*args, **kwargs)
---> 19 return model.Var(name, dist, data)
20 elif name is None:
21 return object.__new__(cls) #for pickle
/Users/fonnescj/Code/pymc/pymc/model.pyc in Var(self, name, dist, data)
145 self.free_RVs.append(var)
146 else:
--> 147 var = ObservedRV(name=name, data=data, distribution=dist, model=self)
148 self.observed_RVs.append(var)
149 self.add_random_variable(var)
/Users/fonnescj/Code/pymc/pymc/model.pyc in __init__(self, name, data, distribution, model)
355 args = [t.constant(args[0], name=name)]
356
--> 357 self.logp_elemwiset = distribution.logp(*args)
358 self.model = model
359
TypeError: logp() takes exactly 2 arguments (3 given)