@@ -20,12 +20,26 @@ using Random
20
20
model = DensityModel (density)
21
21
22
22
# Set up our sampler with initial parameters.
23
- spl = MetropolisHastings ([0.0 , 0.0 ])
23
+ spl1 = RWMH ([0.0 , 0.0 ])
24
+ spl2 = StaticMH ([0.0 , 0.0 ], MvNormal ([0.0 , 0.0 ], 1 )
24
25
25
- # Sample from the posterior.
26
- chain = sample (model, spl, 100000 ; param_names= [" μ" , " σ" ])
26
+ @testset " Inference" begin
27
27
28
- # chn_mean ≈ dist_mean atol=atol_v
29
- @test mean (chain[" μ" ]. value) ≈ 0.0 atol= 0.1
30
- @test mean (chain[" σ" ]. value) ≈ 1.0 atol= 0.1
28
+ # Sample from the posterior.
29
+ chain1 = sample (model, spl1, 100000 ; param_names= [" μ" , " σ" ])
30
+ chain2 = sample (model, spl2, 100000 ; param_names= [" μ" , " σ" ])
31
+
32
+ # chn_mean ≈ dist_mean atol=atol_v
33
+ @test mean (chain1[" μ" ]. value) ≈ 0.0 atol= 0.1
34
+ @test mean (chain1[" σ" ]. value) ≈ 1.0 atol= 0.1
35
+ @test mean (chain2[" μ" ]. value) ≈ 0.0 atol= 0.1
36
+ @test mean (chain2[" σ" ]. value) ≈ 1.0 atol= 0.1
37
+ end
38
+
39
+ @testset " psample" begin
40
+ chain1 = psample (model, spl1, 10000 , 4 )
41
+ @test mean (chain1[" μ" ]. value) ≈ 0.0 atol= 0.1
42
+ @test mean (chain1[" σ" ]. value) ≈ 1.0 atol= 0.1
43
+ end
31
44
end
45
+
0 commit comments