*kf
by An Uncommon Lab

bnddraw

Draw ns sets of samples from a bivariate normal distribution with positive semi-definite covariance matrix, C.

draws = bnddraw(C, ns)

Inputs

C

Positive semi-definite covariance matrix

ns

Number of sets of samples to draw

Outputs

d

Random draws with covariance C (that is, cov(d.') approaches C for large ns)

Example

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

See Also

randcov, sqrtpsdm

Table of Contents

  1. Inputs
  2. Outputs
  3. Example
  4. See Also