TuringLang / Turing.jl

Bayesian inference with probabilistic programming.
https://turinglang.org
MIT License
2.03k stars 218 forks source link

Dependent uniform variables not working correctly #2245

Closed evolbeginner closed 3 months ago

evolbeginner commented 4 months ago

In the following code I want to sample two variables, X1 ~ Uniform(0,1)and X2 ~ Uniform(0,X1)

using Turing
@model function model()
X1 ~ Uniform(1e-5, 1)
X2 ~ Uniform(0, X1)
end
my_model = model(); sample(my_model, NUTS(), 10000)

The mean of X2 should be 0.25 but I got it varying a lot each time. I believe X2 is not sampled correctly. I don't see the problem if X2 ~ Normal(X1,1)or X2 ~ Exponential(X1). Does anyone know why this issue happens and why it's specific to uniform distribution? Thanks in advance.

image image

evolbeginner commented 3 months ago

I think it's fixed in v0.32.3. Thanks!

yebai commented 3 months ago

related PR: https://github.com/TuringLang/Turing.jl/pull/2202