I have tried below simple code of PyMC3 in Python 3.7 in order to generate lambda value of exponential function.
But I am getting below error instead.
Could you please let me what the problem is?
import pymc3 as pm
lambda_1 = pm.Exponential('lambda_1', 1)
lambda_2 = pm.Exponential('lambda_2', 1)
TypeError: No model on context stack, which is needed to instantiate distributions. Add variable inside a 'with model:' block, or use the '.dist' syntax for a standalone distribution.
Try this:
import pymc3 as pm
with pm.Model() as model:
lambda_1 = pm.Exponential('lambda_1', 1)
lambda_1 = pm.Exponential('lambda_2', 1)
I guarantee that it will remove your error! Happy Coding!