IS() actually just samples from the prior. I won't go into a long explanation of why the code make this happen, I'll just demonstrate.
The following is running on Turing v0.35 (current version at the time of writing is v0.42), so this behaviour is not new at all, and hasn't been affected by any of the large-scale refactors recently:
julia> using Turing; @model function f()
x ~ Normal()
2.0 ~ Normal(x)
end
f (generic function with 2 methods)
julia> chn = sample(f(), IS(), 1000); mean(chn[:x])
Sampling 100%|██████████████████████████████████| Time: 0:00:00
-0.03880946669246747
I am guessing that the idea is that you want to weight the samples by the logjoint and then resample from them, so something like this
julia> using LogExpFunctions: softmax
julia> d = Categorical(softmax(vec(chn[:lp]))); # in recent versions chn[:logjoint] instead
julia> ixs = rand(d, 1000);
julia> resampled = chn[:x][ixs];
julia> mean(resampled)
0.9939947232663507
But the sampler itself doesn't do that for you (so it's not really performing importance sampling), and Turing doesn't have a convenience function for that. So you could just as well have done this with Prior().
Furthermore, given that nobody has complained about this, I'm willing to bet almost nobody is actually using it.
Given this, shouldn't we just delete IS()?
IS()actually just samples from the prior. I won't go into a long explanation of why the code make this happen, I'll just demonstrate.The following is running on Turing v0.35 (current version at the time of writing is v0.42), so this behaviour is not new at all, and hasn't been affected by any of the large-scale refactors recently:
I am guessing that the idea is that you want to weight the samples by the logjoint and then resample from them, so something like this
But the sampler itself doesn't do that for you (so it's not really performing importance sampling), and Turing doesn't have a convenience function for that. So you could just as well have done this with
Prior().Furthermore, given that nobody has complained about this, I'm willing to bet almost nobody is actually using it.
Given this, shouldn't we just delete
IS()?