Skip to content

Commit a277c29

Browse files
committed
Add MH test for LKJCholesky
1 parent 188bd80 commit a277c29

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/mcmc/mh.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,23 @@ GKernel(var) = (x) -> Normal(x, sqrt.(var))
206206
end
207207
end
208208

209+
@testset "LKJCholesky" begin
210+
for uplo in ['L', 'U']
211+
@model f() = x ~ LKJCholesky(2, 1, uplo)
212+
Random.seed!(100)
213+
chain = sample(f(), MH(), 5_000)
214+
indices = [(1, 1), (2, 1), (2, 2)]
215+
values = [1, 0, 0.785]
216+
for ((i, j), v) in zip(indices, values)
217+
if uplo == 'U' # Transpose
218+
@test mean(chain, "x.$uplo[$j, $i]") v atol = 0.01
219+
else
220+
@test mean(chain, "x.$uplo[$i, $j]") v atol = 0.01
221+
end
222+
end
223+
end
224+
end
225+
209226
@testset "MH link/invlink" begin
210227
vi_base = DynamicPPL.VarInfo(gdemo_default)
211228

0 commit comments

Comments
 (0)