Question on Bayesian Inference with Julia, using Turing and/or AdvancedHMC and/or Distributions

If you want to use Turing, as @mohamed82008 mentioned you can write the model as follows:

using Turing

@model mymodel(Y, w) = begin
    mu ~ Normal()
    sigma ~ truncated(Cauchy(0, 5), 0, Inf)
    for y in Y
        @logpdf() += w * logpdf(Normal(mu, sigma), y) - pdf(Normal(mu/10, sigma^(1/2)), y)
    end
end

result = sample(mymodel(data, 1.0), NUTS(0.7), 1000)
4 Likes