@@ -37,32 +37,40 @@ include("util.jl")
37
37
# Set up our sampler with initial parameters.
38
38
spl1 = StaticMH ([Normal (0 ,1 ), Normal (0 , 1 )])
39
39
spl2 = StaticMH (MvNormal (zeros (2 ), I))
40
+ spl3 = StaticMH (2 )
40
41
41
42
# Sample from the posterior.
42
43
chain1 = sample (model, spl1, 100000 ; chain_type= StructArray, param_names= [" μ" , " σ" ])
43
44
chain2 = sample (model, spl2, 100000 ; chain_type= StructArray, param_names= [" μ" , " σ" ])
45
+ chain3 = sample (model, spl3, 100000 ; chain_type= StructArray, param_names= [" μ" , " σ" ])
44
46
45
47
# chn_mean ≈ dist_mean atol=atol_v
46
48
@test mean (chain1. μ) ≈ 0.0 atol= 0.1
47
49
@test mean (chain1. σ) ≈ 1.0 atol= 0.1
48
50
@test mean (chain2. μ) ≈ 0.0 atol= 0.1
49
51
@test mean (chain2. σ) ≈ 1.0 atol= 0.1
52
+ @test mean (chain3. μ) ≈ 0.0 atol= 0.1
53
+ @test mean (chain3. σ) ≈ 1.0 atol= 0.1
50
54
end
51
55
52
56
@testset " RandomWalk" begin
53
57
# Set up our sampler with initial parameters.
54
58
spl1 = RWMH ([Normal (0 ,1 ), Normal (0 , 1 )])
55
59
spl2 = RWMH (MvNormal (zeros (2 ), I))
60
+ spl3 = RWMH (2 )
56
61
57
62
# Sample from the posterior.
58
63
chain1 = sample (model, spl1, 100000 ; chain_type= StructArray, param_names= [" μ" , " σ" ])
59
64
chain2 = sample (model, spl2, 100000 ; chain_type= StructArray, param_names= [" μ" , " σ" ])
65
+ chain3 = sample (model, spl3, 200000 ; chain_type= StructArray, param_names= [" μ" , " σ" ])
60
66
61
67
# chn_mean ≈ dist_mean atol=atol_v
62
68
@test mean (chain1. μ) ≈ 0.0 atol= 0.1
63
69
@test mean (chain1. σ) ≈ 1.0 atol= 0.1
64
70
@test mean (chain2. μ) ≈ 0.0 atol= 0.1
65
71
@test mean (chain2. σ) ≈ 1.0 atol= 0.1
72
+ @test mean (chain3. μ) ≈ 0.0 atol= 0.1
73
+ @test mean (chain3. σ) ≈ 1.0 atol= 0.1
66
74
end
67
75
68
76
@testset " parallel sampling" begin
0 commit comments