### Function Reference: `mvnrnd`

statistics: r = mvnrnd (mu, sigma)
statistics: r = mvnrnd (mu, sigma, n)
statistics: r = mvnrnd (mu, sigma, n, T)
statistics: [r, T] = mvnrnd (…)

Random vectors from the multivariate normal distribution.

`r = mvnrnd (mu, sigma)` returns an N-by-D matrix r of random vectors chosen from the multivariate normal distribution with mean vector mu and covariance matrix sigma. mu is an N-by-D matrix, and `mvnrnd` generates each N of r using the corresponding N of mu. sigma is a D-by-D symmetric positive semi-definite matrix, or a D-by-D-by-N array. If sigma is an array, `mvnrnd` generates each N of r using the corresponding page of sigma, i.e., `mvnrnd` computes r(i,:) using mu(i,:) and sigma(:,:,i). If the covariance matrix is diagonal, containing variances along the diagonal and zero covariances off the diagonal, sigma may also be specified as a 1-by-D matrix or a 1-by-D-by-N array, containing just the diagonal. If mu is a 1-by-D vector, `mvnrnd` replicates it to match the trailing dimension of SIGMA.

`r = mvnrnd (mu, sigma, n)` returns a N-by-D matrix R of random vectors chosen from the multivariate normal distribution with 1-by-D mean vector mu, and D-by-D covariance matrix sigma.

`r = mvnrnd (mu, sigma, n, T)` supplies the Cholesky factor T of sigma, so that sigma(:,:,J) == T(:,:,J)’*T(:,:,J) if sigma is a 3D array or sigma == T’*T if sigma is a matrix. No error checking is done on T.

`[r, T] = mvnrnd (…)` returns the Cholesky factor T, so it can be re-used to make later calls more efficient, although there are greater efficiency gains when SIGMA can be specified as a diagonal instead.

See also: mvncdf, mvnpdf

Source Code: mvnrnd