*kf
by An Uncommon Lab

mnddraw

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

draws = mnddraw(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 = 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

See Also

randcov, sqrtpsdm, pmfdraw

Table of Contents

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