Draw ns
sets of samples from a multivariate normal distribution with
positive semi-definite covariance matrix, C
.
draws = mnddraw(C, ns)
C | Positive semi-definite covariance matrix |
---|---|
ns | Number of sets of samples to draw |
d | Random draws with covariance C (that is, |
---|
Make a 3-by-3 positive definite covariance matrix.
C = randcov(3);
Make 1,000,000 sets of draws from it, yielding a 3-by-1,000,000 matrix.
d = mnddraw(C, 1e6);
Calculate the resulting covariance and compare to original.
C_empirical = cov(d.')
C
C_empirical =
0.5055 -0.2306 -0.2071
-0.2306 0.5125 -0.0716
-0.2071 -0.0716 0.7527
C =
0.5052 -0.2311 -0.2059
-0.2311 0.5124 -0.0714
-0.2059 -0.0714 0.7502
*kf
v1.0.3