rmvtnorm: Random multivariate normal variables

rmvtnormR Documentation

Random multivariate normal variables

Description

Draw vectors from a multivariate normal distribution.

Usage

rmvtnorm (n = 1, k = 2, means = rep (0, k), sigma = diag (k))

Arguments

n

The number of vectors to be drawn.

k

The dimension of the vectors to be drawn.

means

A vector of means, one for each dimension.

sigma

The covariance matrix of the distribution. If a number between 0 and 1 is provided, this is assumed to be the correlation parameter for a bivariate standard normal distribution.

Details

If means and sigma are not specified, a standard normal distribution is assumed along every dimensions, and dimensions are assumed to be uncorrelated. If the number of dimensions is not specified, a bivariate distribution is assumed.

Value

A matrix with rows equal to n and columns equal to k, where each row indicates a single observation, and each column represents a different dimension.

Author(s)

Santiago Barreda <sbarreda@ucdavis.edu>

Examples

## Examples of draws from different bivariate normal distributions
## and standard deviation ellipses drawn to fit them.
#par (mfrow = c(2,2))
#draws = rmvtnorm (n = 1000, k = 2, sigma = .3)
#plot (draws)
#sdellipse (draws, stdev = 3, lwd = 3, col = 2)

#draws = rmvtnorm (n = 1000, k = 2, sigma = -.3)
#plot (draws)
#sdellipse (draws, stdev = 3, lwd = 3, col = 2)

#draws = rmvtnorm (n = 1000, k = 2, sigma = -.7)
#plot (draws)
#sdellipse (draws, stdev = 3, lwd = 3, col = 2)

#draws = rmvtnorm (n = 1000, k = 2, sigma = .7)
#plot (draws)
#sdellipse (draws, stdev = 3, lwd = 3, col = 2)

phonTools documentation built on Nov. 21, 2023, 1:07 a.m.