Hey all,

I’ve been trying to practice turing.jl and Julia as a whole and its been a great experience so far!

I am having some trouble coming from pymc3 background, any help and direction is much appreciated!

Given the code from the (amazing) book on Bayesian methods for Hackers:

```
import pymc3 as pm
import theano.tensor as tt
with pm.Model() as model:
alpha = 1.0/count_data.mean() # Recall count_data is the
# variable that holds our txt counts
lambda_1 = pm.Exponential("lambda_1", alpha)
lambda_2 = pm.Exponential("lambda_2", alpha)
tau = pm.DiscreteUniform("tau", lower=0, upper=n_count_data - 1)
idx = np.arange(n_count_data) # Index
lambda_ = pm.math.switch(tau > idx, lambda_1, lambda_2)
observation = pm.Poisson("obs", lambda_, observed=count_data)
step = pm.Metropolis()
trace = pm.sample(10000, tune=5000,step=step)
```

my translation is:

```
@model text_model(y) = begin
α = 1/mean(y)
λ₁ ~ Exponential(α)
λ₂ ~ Exponential(α)
τ ~ DiscreteUniform(1, length(y))
function equality(idx)
if τ > idx
return λ₁
end
return λ₂
end
times = 1:length(y)
λ = map(equality, times)
for idx in times
y[idx] ~ Poisson(λ[idx])
end
return τ
end
model = model(data.count)
trace = sample(model, Gibbs(HMC(0.01, 10, :λ₁, :λ₂), PG(20, :τ)), 1000)
```

There are no errors (other than warning of rejected proposals for numerical reasons once in a while) and the sampling goes on without a problem.

The problem is that I get the wrong results .

Question:

Do you think the code translation makes sense? not super sure about the switchpoint method I am using.

Thanks in advance Julia and Turing Communities!