Fixed distribution in Turing

Hi all,

Is it possible to sample a distribution in Turing without updating it?

For example from this tutorial: https://turing.ml/dev/tutorials/10-bayesian-differential-equations/

@model function fitlv(data, prob)
    # Prior distributions.
    σ ~ InverseGamma(2, 3)
    α ~ truncated(Normal(1.5, 0.5), 0.5, 2.5)
    β ~ truncated(Normal(1.2, 0.5), 0, 2)
    γ ~ truncated(Normal(3.0, 0.5), 1, 4)
    δ ~ truncated(Normal(1.0, 0.5), 0, 2)

    # Simulate Lotka-Volterra model. 
    p = [α, β, γ, δ]
    predicted = solve(prob, Tsit5(); p=p, saveat=0.1)

    # Observations.
    for i in 1:length(predicted)
        data[:, i] ~ MvNormal(predicted[i], σ^2 * I)
    end

    return nothing
end

model = fitlv(odedata, prob)

# Sample 3 independent chains with forward-mode automatic differentiation (the default).
chain = sample(model, NUTS(0.65), MCMCSerial(), 1000, 3; progress=false)

Let’s say that I already know the distribution of α but not β, γ, δ. How to consider the α distribution as a “fixed” distribution and keep track of the samples while still estimating the posteriors for the other parameters?

Many thanks.

This question came up here a few years ago:

See also this issue:

I’ve had cases where this would be really useful. There is a Prior() sampler, but it doesn’t seem to have a method accepting a symbol to tell it which variables to apply it to inside a Gibbs sampler.

1 Like

Thanks a lot @ElOceanografo!