Posterior samples as vector of named tuples

Let’s say I have a simple Turing model

@model function model()
    C ~ LKJ(3, 1.0)
    x ~ MvNormal(zeros(3), C)
end

and obtained some posterior samples via MCMC

chain = sample(model(), NUTS(), 100)

or variational inference

q = vi(model(), ADVI(10, 1_000))
samples = rand(q, 100)

Is there an (easy) way to transform such samples into a vector of named tuples, i.e., [(C = Matrix, x = Vector), (C = Matrix, x = Vector), ...] corresponding to the sampled random variables of the Turing model?
Could not find it in the documentation (hope to have just missed it).

What are you trying to accomplish that requires the vector of named tuples?

Basically, I wanted to condition the model on some of its parameters using the posterior mean or a couple of samples as values.
Have found a way to do it though, e.g., DynamicPPL.value_iterator_from_chain provides samples in a suitable format.

1 Like

Here is something that might be along those lines: API · DynamicPPL