zenna / Omega.jl

Causal, Higher-Order, Probabilistic Programming
MIT License
164 stars 17 forks source link

Propagating conditions with RCD #193

Open zenna opened 2 years ago

zenna commented 2 years ago

One of the things that concerns me is that I think it's possible for RCD to be incorrect in the sense that an inner expectation does not take into account external conditions.

julia> ϵ = @~ Normal(0, 1)
julia> μ = @~ Categorical([0.1, 0.3, 0.6])
julia> x = pw(+, μ, ϵ)
julia> 𝔼(x; k=1_000) = randsample(Random.MersennteTwister(0), x, k)
julia> using Random
julia> 𝔼(x; k=1_000) = mean(randsample(Random.MersenneTwister(0), x, k))
julia> pw(𝔼, rid(x, μ))
julia> UnicodePlots.histogram(randsample(pw(𝔼, rid(x, μ)), 1000))
UnicodePlots.histogram(randsample(pw(𝔼, rid(x, μ)) |ᶜ (ϵ >ₚ 0.0), 1000))
UnicodePlots.histogram(randsample(pw(𝔼, rid(x |ᶜ (ϵ >ₚ 0.0), μ)), 1000))

Point is that the last two plots are different, and that the last one is correct.