my goal : I’d like to use a custom distribution as a mixture component.
This is my ‘basic’ code. It works ok to build a log-normal mixture model that fit (more or less) my data :
l_nbr = 3 # number of components l_mu = pm.Halfnormal('l_mu'),sd=1,shape=l_nbr) l_sd = m.HalfNormal('l_sd_1',mu=l_sd_prior,sd=1,shape=l_nbr) l_comp = pm.Lognormal.dist(mu=l_mu,sd=l_sd,shape=l_nbr) l_w = pm.Dirichlet('l_w_1',a=np.array(*l_nbr)) l_mix = pm.Mixture('l_mix',w=l_w,comp_dists=l_comp,observed=data)
But I expect that using log-normal with some little offset would work even better,
so I create a new random variable ‘l_offset’ :
l_offset = pm.HalfNormal(sd=1,shape=l_nbr)
… and I try to add it to my previous mixture components :
l_comp = l_comp + l_offset
The rest of the code is unchanged.
I get the following error on the sum code line :
AsTensorError: ('Cannot convert <pymc3.distributions.continuous.Lognormal object at 0x7f5168092390> to TensorType', <class 'pymc3.distributions.continuous.Lognormal'>)
I understand it as the impossibility to add a sampled RV (the offset) to the components (the log-normal distributions) that are not (directly) sampled…
Any idea to work around this problem will be appreciated.