This option seems very nice to me, however when running the following code:
import pymc3 as pm
class Translate(pm.distributions.transforms.Transform):
def __init__(self, v):
self.v_ = v
def forward(self, x):
return x + self.v_
def forward_val(self, x):
return x + self.v_
def backward(self, x):
return x - self.v_
def jacobian_det(self, x):
return 0. * x # log(1) = 0
def apply(self, dist):
return pm.distributions.transforms.TransformedDistribution.dist(dist, self)
with pm.Model() as model:
l = pm.Gamma('l_pr', alpha=3, beta=3)
a = pm.Gamma('a', alpha=3, beta=3)
b = pm.Gamma('b', alpha=3, beta=3)
shift = Translate(l)
weib = shift.apply(pm.Weibull('base', alpha=a, beta=b))
trace = pm.sample(100)
I get the following error:
Traceback (most recent call last):
File "C:/Users/xxx/source/xxx/run_scripts/xxx/test.py", line 28, in <module>
weib = shift.apply(pm.Weibull('base', alpha=a, beta=b))
File "C:/Users/xxx/source/xxx/run_scripts/xxx/test.py", line 21, in apply
return pm.distributions.transforms.TransformedDistribution.dist(dist, self)
File "C:\Users\xxx\AppData\Local\Continuum\anaconda3\envs\xxx\lib\site-packages\pymc3\distributions\distribution.py", line 52, in dist
dist.__init__(*args, **kwargs)
File "C:\Users\xxx\AppData\Local\Continuum\anaconda3\envs\xxx\lib\site-packages\pymc3\distributions\transforms.py", line 120, in __init__
testval = forward(dist.default())
AttributeError: 'TransformedRV' object has no attribute 'default'
Thanks!