PosDefException in MvNormal

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

PosDefException in MvNormal

Jon Alm Eriksen
Hi there,

I try to generate correlated multivariate normal samples, but it turns out that MvNormal does not accept all covariance matrices. For example:

cov = [1.0       0.780645  0.523948;
       0.780645  1.0       0.954903;
       0.523948  0.954903  1.0]
MvNormal(cov)

yields the following:

PosDefException(3)
while loading In[130], in expression starting on line 4

 in cholfact! at linalg/factorization.jl:38
 in cholfact at linalg/factorization.jl:41 (repeats 2 times)
 in MvNormal at /Users/jonalm/.julia/v0.3/Distributions/src/multivariate/mvnormal.jl:91

Is this a bug, or is there an inherent limitation to the valid covariance matrices? Is there a work around?

I believe this issue has been discussed before:
https://groups.google.com/forum/#!topic/julia-stats/KMXBp75CUEc
But I do not really understand how I can implement the suggested solution?

best
Jon Alm Eriksen

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: PosDefException in MvNormal

Jon Alm Eriksen
My bad. Stupid question. The cov matrix in the question is not
positive definite!

On Mon, Sep 28, 2015 at 1:22 PM, Jon Alm Eriksen
<[hidden email]> wrote:

> Hi there,
>
> I try to generate correlated multivariate normal samples, but it turns out
> that MvNormal does not accept all covariance matrices. For example:
>
> cov = [1.0       0.780645  0.523948;
>        0.780645  1.0       0.954903;
>        0.523948  0.954903  1.0]
> MvNormal(cov)
>
> yields the following:
>
>
> PosDefException(3)
> while loading In[130], in expression starting on line 4
>
>  in cholfact! at linalg/factorization.jl:38
>  in cholfact at linalg/factorization.jl:41 (repeats 2 times)
>  in MvNormal at
> /Users/jonalm/.julia/v0.3/Distributions/src/multivariate/mvnormal.jl:91
>
>
> Is this a bug, or is there an inherent limitation to the valid covariance
> matrices? Is there a work around?
>
> I believe this issue has been discussed before:
> https://groups.google.com/forum/#!topic/julia-stats/KMXBp75CUEc
> But I do not really understand how I can implement the suggested solution?
>
> best
> Jon Alm Eriksen
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "julia-stats" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/julia-stats/Nb7d5bVM5UQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "julia-stats" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.