I’m trying to convert a model from Bayesian Methods For Hackers Ch. 1 from pymc 2 to 3. The relevant piece of code in the original is:
@pm.deterministic
def lambda_(tau=tau, lambda_1=lambda_1, lambda_2=lambda_2):
out = np.zeros(n_count_data)
out[:tau] = lambda_1 # lambda before tau is lambda1
out[tau:] = lambda_2 # lambda after (and including) tau is lambda2
return out
observation = pm.Poisson("obs", lambda_, value=count_data, observed=True)
I’m not sure how to convert this to pymc3. I can perform “basic” deterministic math on RVs directly (because of operator overloading), but it doesn’t look like slicing was overloaded, so if I write:
out = np.zeros(n_count_data)
out[:tau] = lambda_1
I get ‘TypeError: slice indices must be integers or None or have an index method’
Advice welcome.
Best,
rif