Skip to content

Commit 902c98e

Browse files
chriselroddevmotionsethaxen
authored
Fix undef ref in lkj_chol sampling (#1782)
* Fix undef ref in lkj_chol sampling * Add test for dim=1 lkjcholesky * Update test/cholesky/lkjcholesky.jl Co-authored-by: David Widmann <[email protected]> * Update test/cholesky/lkjcholesky.jl Co-authored-by: Seth Axen <[email protected]> * Update test/cholesky/lkjcholesky.jl Co-authored-by: David Widmann <[email protected]> --------- Co-authored-by: David Widmann <[email protected]> Co-authored-by: Seth Axen <[email protected]>
1 parent 87aebc2 commit 902c98e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/cholesky/lkjcholesky.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ function _lkj_cholesky_onion_tri!(
238238
# equivalent steps in algorithm in reference are marked.
239239
@assert size(A) == (d, d)
240240
A[1, 1] = 1
241-
d > 1 || return R
241+
d > 1 || return A
242242
β = η + (d - 2)//2
243243
# 1. Initialization
244244
w0 = 2 * rand(rng, Beta(β, β)) - 1

test/cholesky/lkjcholesky.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ using FiniteDifferences
181181
nkstests = 4 # use for appropriate Bonferroni correction for KS test
182182

183183
@testset "rand" begin
184+
@test rand(LKJCholesky(1, 0.5)).factors == ones(1, 1)
184185
@testset for p in (2, 4, 10), η in (0.5, 1, 3), uplo in ('L', 'U')
185186
d = LKJCholesky(p, η, uplo)
186187
test_draw(d, rand(rng, d))

0 commit comments

Comments
 (0)