The summary of my problem is that I am trying to replicate the Matlab function:
mvnrnd(mu', sigma, 200)
into Julia using:
rand( MvNormal(mu, sigma), 200)'
and the result is a 200 x 7 matrix, essentially generating 200 random return time series data.
Matlab works, Julia doesn't.
My input matrices are:
mu = [0.15; 0.03; 0.06; 0.04; 0.1; 0.02; 0.12]
sigma = [0.0035   -0.0038   0.0020    0.0017    -0.0006   -0.0028  0.0009;
    -0.0038    0.0046   -0.0011    0.0001    0.0003    0.0054   -0.0024;
    0.0020   -0.0011    0.0041    0.0068   -0.0004    0.0047   -0.0036;
    0.0017    0.0001    0.0068    0.0125    0.0002    0.0109   -0.0078;
    -0.0006    0.0003   -0.0004    0.0002    0.0025   -0.0004   -0.0007;
    -0.0028    0.0054    0.0047    0.0109   -0.0004    0.0159   -0.0093;
    0.0009   -0.0024   -0.0036   -0.0078   -0.0007   -0.0093    0.0061]
Using Distributions.jl, running the line:
MvNormal(sigma)
Produces the error:
ERROR: LoadError: Base.LinAlg.PosDefException(4)
The matrix sigma is symmetrical but only positive semi-definite:
issym(sigma) #symmetrical
> true
isposdef(sigma) #positive definite
> false
using LinearOperators
check_positive_definite(sigma) #check for positive (semi-)definite
> true
Matlab produces the same results for these tests however Matlab is able to generate the 200x7 random return sample matrix.
Could someone advise as to what I could do to get it working in Julia? Or where the issue lies?
Thanks.