Hi, I am using PYMC 5, for marketing modeling. One of the steps during the model is to transform the variables using an adstock function. I am trying to use Weibull Probability Density Function (PDF) here:
def weibull_pdf(x, lambda_, k):
x = np.asarray(x)
pdf = (k / lambda_) * (x / lambda_)**(k - 1) * np.exp(-((x / lambda_)**k))
return pdf
This function is giving me an error message and I think with aesara there is an issue where this cannot be into the adequate variable type during the process.
import aesara.tensor as at
def weibull_pdf(x, lambda_, k):
x = at.as_tensor_variable(x)
pdf = (k / lambda_) * (x / lambda_)**(k - 1) * at.exp(-((x / lambda_)**k))
return pdf
A fake model to test the function:
with pm.Model() as model:
lambda_ = pm.Exponential('lambda_', 1.0)
k = pm.Exponential('k', 1.0)
x = np.linspace(0, 5, 100)
weibull = weibull_pdf(x, lambda_, k)
y_obs = pm.Normal('y_obs', mu=weibull, sigma=0.1, observed=np.random.normal(weibull, 0.1))
trace = pm.sample(1000)
NotImplementedError: Cannot convert lambda_ to a tensor variable.
PS: Chatgpt cannot help on this…
Thank you