Produces one or more samples from the specified multivariate normal distribution.

mvrnorm(n = 1, mu, Sigma, tol = 1e-6, empirical = FALSE, EISPACK = FALSE)

If n = 1 a vector of the same length as mu, otherwise an

n = 1

mu

n by length(mu) matrix with one sample in each row.

n

length(mu)

the number of samples required.

a vector giving the means of the variables.

a positive-definite symmetric matrix specifying the covariance matrix of the variables.

tolerance (relative to largest variance) for numerical lack of positive-definiteness in Sigma.

Sigma

logical. If true, mu and Sigma specify the empirical not population mean and covariance matrix.

logical: values other than FALSE are an error.

FALSE

Causes creation of the dataset .Random.seed if it does not already exist, otherwise its value is updated.

.Random.seed

The matrix decomposition is done via eigen; although a Choleski decomposition might be faster, the eigendecomposition is stabler.

eigen

B. D. Ripley (1987) Stochastic Simulation. Wiley. Page 98.

rnorm

Sigma <- matrix(c(10,3,3,2),2,2) Sigma var(mvrnorm(n = 1000, rep(0, 2), Sigma)) var(mvrnorm(n = 1000, rep(0, 2), Sigma, empirical = TRUE))

Run the code above in your browser using DataCamp Workspace