Hi @cluhmann,
To be more precise, I have a mean function that I know via Least square’s regression whose function is given by:
f(x) = a1*exp(-((x-b1)/c1)^2) + a2*exp(-((x-b2)/c2)^2) +
a3*exp(-((x-b3)/c3)^2) + a4*exp(-((x-b4)/c4)^2) +
a5*exp(-((x-b5)/c5)^2)
Here, “x” is the predictor variable and all others are the unknown parameters (a1,a2,…b1,b2,…c1,c2,…).
I want to model this in PyMC3 considering all these unknown parameters as RVs. I have already tried defining a function and using it as follows:
with pm.Model() as model:
def sumGaussians(a,b,c,x):
sum = tt.zeros (shape=(1,26))
for g in range(numG):
sum = sum + a[g] * pm.math.exp(pm.math.sqr((x - b[g])/c[g]))
return sum
a_ = pm.Normal("a_", mu=0, sigma=sigma_theta, shape=(numG, 1))
b_ = pm.Normal("b_", mu=0, sigma=sigma_theta, shape=(numG, 1))
c_ = pm.Normal("c_", mu=0, sigma=sigma_theta, shape=(numG, 1))
mu_y = sumGaussians(a_,b_,c_,x)
sigma_y = pm.InverseGamma("sigma_y",1,1)
Y_obs = pm.Normal('Y_obs', mu_y, sigma_y, observed=obs_data)
This doesn’t work for me. What do you think is going wrong for me?