I used the below code to create a matrix of wishart distribution,
clc
sigma =eye(100); df=2;mu=zeros(100,1);
wishart_matrix=wishart_distribution(sigma,df)
normal_vector=mvnrnd(mu,inv(w1),1);
function W=wishart_distribution(sigma,df)
W = wishrnd(sigma,df);
end
function G = gauss_distribution(mu, sigma,count)
rng default % For reproducibility
G = mvnrnd(mu,sigma,count);
end
I encountered the below error, it seems inv(sigma) is not positive semi-definite matrix, how can i fix it?
Error using mvnrnd (line 110)
SIGMA must be a symmetric positive semi-definite matrix.
Error in sahar_vbssm>gauss_distribution (line 323)
G = mvnrnd(mu,sigma,count);
To generate a random positive definite matrix in MATLAB, use