File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 320
320
@test isapprox (std (num_ms), 1.8865 ; atol= 0.02 )
321
321
end
322
322
323
+ # The below test used to sample incorrectly before
324
+ # https://github.com/TuringLang/Turing.jl/pull/2328
325
+ @testset " dynamic model with ESS" begin
326
+ @model function dynamic_model_for_ess ()
327
+ b ~ Bernoulli ()
328
+ x_length = b ? 1 : 2
329
+ x = Vector {Float64} (undef, x_length)
330
+ for i in 1 : x_length
331
+ x[i] ~ Normal (i, 1.0 )
332
+ end
333
+ end
334
+
335
+ m = dynamic_model_for_ess ()
336
+ chain = sample (m, Gibbs (:b => PG (10 ), :x => ESS ()), 2000 ; discard_initial= 100 )
337
+ means = Dict (:b => 0.5 , " x[1]" => 1.0 , " x[2]" => 2.0 )
338
+ stds = Dict (:b => 0.5 , " x[1]" => 1.0 , " x[2]" => 1.0 )
339
+ for vn in keys (means)
340
+ @test isapprox (mean (skipmissing (chain[:, vn, 1 ])), means[vn]; atol= 0.1 )
341
+ @test isapprox (std (skipmissing (chain[:, vn, 1 ])), stds[vn]; atol= 0.1 )
342
+ end
343
+ end
344
+
323
345
@testset " dynamic model with dot tilde" begin
324
346
@model function dynamic_model_with_dot_tilde (
325
347
num_zs= 10 , :: Type{M} = Vector{Float64}
You can’t perform that action at this time.
0 commit comments