The RANDNORMAL function is part of the IMLMLIB library . The RANDNORMAL function returns an matrix that contains N random draws from the multivariate normal distribution with mean vector Mean and covariance matrix Cov.
The inputs are as follows:
is the number of desired observations sampled from the multivariate normal distribution.
is a vector of means.
is a symmetric positive definite variance-covariance matrix.
If X follows a multivariate normal distribution with mean vector and variance-covariance matrix , then
the probability density function for x is
if , the probability density function reduces to a univariate normal distribution.
the expected value of is .
the covariance of and is .
The following example generates 1,000 samples from a two-dimensional multivariate normal distribution with mean vector and a given covariance matrix. Each row of the returned matrix x
is a row vector sampled from the multivariate normal distribution. The example computes the sample mean and covariance and
compares them with the expected values.
call randseed(1); N = 1000; Mean = {1 2}; Cov = {2.4 3, 3 8.1}; x = RandNormal( N, Mean, Cov ); SampleMean = mean(x); SampleCov = cov(x); print SampleMean Mean, SampleCov Cov;
For further details about sampling from the multivariate normal distribution, see Gentle (2003).