Skip to content

Turing resamples variable that is passed as variable to condition on when querying #190

@mgmverburg

Description

@mgmverburg

When running the below code, one observes that x is being resampled when performing the result1 query, and that a different value for x is therefore printed instead of "1.0" as the value should be (since that is what it is conditioned on).

using Turing, Distributions

@model function gdemo(x, y)
	println("START")
    s ~ InverseGamma(2, 3)
    m ~ Normal(0, sqrt(s))
    x ~ filldist(Normal(m, sqrt(s)), length(y))
    @show x
    for i in 1:length(y)
        @show x[i]
        y[i] ~ Normal(x[i], sqrt(s))
    end
end

model_gdemo = gdemo([1.0, 0.0], [1.5, 0.0])
c2 = sample(model_gdemo, NUTS(0.65), 100)

result1 = prob"y = [1.5] | chain=c2, model = model_gdemo, x = [1.0]"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions