Skip to contents

Sampler derived using the eigendecomposition of the covariance matrix Sigma. The function uses the Armadillo random normal generator

Usage

mvrnorm(n, mu, Sigma)

Arguments

n

sample size

mu

mean vector. Will set the dimension

Sigma

a square covariance matrix, of same dimension as mu. No sanity check is performed to validate that the matrix is p.s.d., so use at own risk

Value

an n sample from a multivariate Normal distribution

Examples

mvrnorm(n=10, mu=c(0,2), Sigma=diag(2))
#>             [,1]      [,2]
#>  [1,]  1.7996324 2.8875935
#>  [2,] -0.1405610 0.2942703
#>  [3,] -0.9402158 1.0888539
#>  [4,] -0.3746384 3.5760637
#>  [5,] -0.8868628 0.2654812
#>  [6,]  0.6565412 1.8267407
#>  [7,]  0.4882522 2.9154757
#>  [8,] -1.3397256 3.6705300
#>  [9,] -0.4402110 3.7359878
#> [10,] -1.0323680 2.2615054