Skip to content

Commit 2e47510

Browse files
committed
Update tests
1 parent e318b17 commit 2e47510

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

test/runtests.jl

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,26 @@ using Random
2020
model = DensityModel(density)
2121

2222
# 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)
2425

25-
# Sample from the posterior.
26-
chain = sample(model, spl, 100000; param_names=["μ", "σ"])
26+
@testset "Inference" begin
2727

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
3144
end
45+

0 commit comments

Comments
 (0)