Turing.jl - Create priors dynamically

Hello everyone,

So in the problem I am currently working on, my parameter space changes a lot, meaning the number of parameters I want to make inference on (using Bayesian statistics, through the Turing.jl package) is not constant.

What I would like to do is to pass a vector of “variable names” and a vector of priors to the Turing model, and it associates each variable name to the corresponding prior (using the tilde operator). So something like:

for (i,var) in enumerate(variable_names)
     var ~ prior_vector[i]
end

Is that possible? Hope the question is clear,
RJ

Is anything in Probabilistic Modelling using the Infinite Mixture Model helpful for you?

2 Likes

Yes! Actually that’s all I needed. For reference, what I did in the Turing model was to first initialise a vector or 0’s, and loop over it to sample from the priors:

p = zeros(float64, length(priors))
for i in eachindex(priors)
    p[i] ~ priors[i]
end

Thanks @sethaxen ! Helped a lot

1 Like