Skip to content

Commit 482e9aa

Browse files
committed
Add test
1 parent b8c26e2 commit 482e9aa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/runtests.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ include("util.jl")
7373
end
7474
end
7575

76+
@testset "MCMCChains" begin
77+
spl1 = StaticMH([Normal(0,1), Normal(0, 1)])
78+
spl2 = MetropolisHastings((μ = StaticProposal(Normal(0,1)), σ = StaticProposal(Normal(0, 1))))
79+
80+
chain1 = sample(model, spl1, 10_000; param_names=["μ", "σ"], chain_type=Chains)
81+
chain2 = sample(model, spl2, 10_000; chain_type=Chains)
82+
83+
@test mean(chain1["μ"]) 0.0 atol=0.1
84+
@test mean(chain1["σ"]) 1.0 atol=0.1
85+
86+
@test mean(chain2["μ"]) 0.0 atol=0.1
87+
@test mean(chain2["σ"]) 1.0 atol=0.1
88+
end
89+
7690
@testset "Proposal styles" begin
7791
m1 = DensityModel(x -> logpdf(Normal(x,1), 1.0))
7892
m2 = DensityModel(x -> logpdf(Normal(x[1], x[2]), 1.0))

0 commit comments

Comments
 (0)