Rfast (version 1.7.3)

Multivariate normal and t random values simulation: Multivariate normal and t random values simulation

Description

Multivariate normal and t random values simulation.

Usage

rmvnorm(n, mu, sigma) rmvt(n, mu, sigma, v)

Arguments

n
The sample size, a numerical value.
mu
The mean vector in $R^d$.
sigma
The covariance matrix in $R^d$.
v
The degrees of freedom.

Value

A matrix with the simulated data.

Details

The algorithm uses univariate normal random values and transforms them to multivariate via a spectral decomposition. It is faster than the command "mvrnorm" available from MASS, and it allows for singular covariance matrices.

References

Aitchison J. (1986). The statistical analysis of compositional data. Chapman & Hall.

See Also

racg, rmvlaplace, rmvt

Examples

Run this code
x <- as.matrix(iris[, 1:4])
m <- colmeans(x)
s <- cov(x)
y <- rmvnorm(1000, m, s)
colmeans(y)
cov(y)

x <- as.matrix(iris[, 1:4])
m <- colmeans(x)
s <- var(x)
y <- rmvt(1000, m, s, 10)
## MASS::cov.trob(y, nu = 10)

Run the code above in your browser using DataLab