2

I have created a positive definite matrix from Wishart in Julia using the Distribution package. I want to use this to generate random multivariate normal with the specified precision. Hence I use the canonical form of MvNormal, which is MvNormalCanon.

However I get a bit confused as the randomly generated matrix from Wishart although positive definite, its inverse is not. So sometimes it causes trouble generating from multivariate normal using that precision.

For example:

using Distributions
X=rand(Wishart(10, eye(10)))
isposdef(X) // true
isposdef(inv(X)) // false

I also use the MvNormalCanon for generating random vectors as below:

rand(MvNormalCanon(X*μ, X))

where μ is my mean vector. But the above creates a Base.LinAlg.PosDefException(1). Should the inverse also be positive definite, and if yes why does Julia act like this?

P.S.It might be adding a tiny bit to the scale matrix in Wishart might resolve the problem.

1
  • 3
    isposdef first checks that the input matrix is Hermitian. In this case, this check fails because of rounding errors from taking the inverse. One solution would be to use the Symmetric wrapper: X = Symmetric(rand(Wishart(10, eye(10)))); iX = inv(X); isposdef(iX) Jul 5, 2017 at 7:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.