I'm trying to build a model that samples from the following joint prior distribution in Pymc3:
f(a,b) ~ (a+b)^(-5/2) where a, b > 0
with pm.Model() as the:
def ab_dist(value=[1.0,1.0]):
return T.switch(any(T.le(value, 0)), -np.Inf, T.log(np.power((value[0] + value[1]), -2.5)))
ab = pm.DensityDist('ab', ab_dist, shape=2, testval = [1,1])
a = ab[0]
b = ab[1]
p = pm.Beta('p', a, b)
trace = pm.sample(20000)
I've followed an example from an issue opened on Pymc3's github page, but am still getting the following error:
ValueError: length not known: Elemwise{le,no_inplace} [id A] ''
|ab [id B]
|DimShuffle{x} [id C] ''
|TensorConstant{0} [id D]
I'm new to Theano and haven't had any success in debugging. I'd like to know the proper way to set this up as well as why I'm receiving the length not known exception. My code is below.
I believe I found my answer. It seems the issue may have been with the any(value) portion of the Theano.Tensor conditional flow. After changing it to T.le(value[0], 0)|T.le(value[1], 0), it seems to work without issues.
Updated code below:
with pm.Model() as the:
def ab_dist(value=[1.0,1.0]):
return T.switch(T.le(value[0], 0)|T.le(value[1], 0), -np.Inf, T.log(np.power((value[0] + value[1]), -2.5)))
ab = pm.DensityDist('ab', ab_dist, shape=2, testval = [1,1])
a = ab[0]
b = ab[1]
p = pm.Beta('p', a, b)
trace = pm.sample(10000)