Draw ns
sets of samples from a bivariate normal distribution with
positive semi-definite covariance matrix, C
.
draws = bnddraw(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 = bnddraw(C, 1e6);
Calculate the resulting covariance and compare to original.
C_empirical = cov(d.')
C
C_empirical =
0.5437 -0.0193 -0.0077
-0.0193 0.4692 -0.0105
-0.0077 -0.0105 0.6705
C =
0.5441 -0.0198 -0.0072
-0.0198 0.4694 -0.0105
-0.0072 -0.0105 0.6704
*kf
v1.0.3