I am learning the pymc package from the book "Bayesian Methods for Hackers: Probabilistic Programming and Bayesian Inference". While executing some codes shown in the picture, I got errors. Does anybody know where is the problem? Is it because of the package installation or version?
For installation of pymc package, I followed the instruction of https://www.pymc.io/projects/docs/en/stable/installation.html
The python code:
import pymc as pm
with pm.Model() as model:
lambda_1 = pm.Exponential("lambda_1", 1)
lambda_2 = pm.Exponential("lambda_2", 1)
tau = pm.DiscreteUniform("tau", lower=0, upper=10)
lambda_1.value
_____________________________________________________________________________
AttributeError Traceback (most recent call last)
Cell In[4], line 6
3 lambda_2 = pm.Exponential("lambda_2", 1)
4 tau = pm.DiscreteUniform("tau", lower=0, upper=10)
----> 6 lambda_1.value
AttributeError: 'TensorVariable' object has no attribute 'value'
_____________________________________________________________________________
@pm.Deterministic
def lambda_(tau=tau, lambda_1=lambda_1, lambda_2=lambda_2):
out = np.zeros(n_data_points)
out[:tau] = lambda_1 # lambda before tau is lambda 1
out[tau:] = lambda_2 # lambda after tau is lambda 2
return out
_____________________________________________________________________________
TypeError Traceback (most recent call last)
Cell In[5], line 1
----> 1 @pm.Deterministic
2 def lambda_(tau=tau, lambda_1=lambda_1, lambda_2=lambda_2):
3 out = np.zeros(n_data_points)
4 out[:tau] = lambda_1 # lambda before tau is lambda 1
TypeError: Deterministic() missing 1 required positional argument: 'var'