Examples for 'mvtnorm::dmvnorm'


Multivariate Normal Density and Random Deviates

Aliases: dmvnorm rmvnorm

Keywords: distribution multivariate

### ** Examples

dmvnorm(x=c(0,0))
[1] 0.1591549
dmvnorm(x=c(0,0), mean=c(1,1))
[1] 0.05854983
sigma <- matrix(c(4,2,2,3), ncol=2)
x <- rmvnorm(n=500, mean=c(1,2), sigma=sigma)
colMeans(x)
[1] 0.971815 1.896896
var(x)
         [,1]     [,2]
[1,] 3.732177 2.041611
[2,] 2.041611 3.216623
x <- rmvnorm(n=500, mean=c(1,2), sigma=sigma, method="chol")
colMeans(x)
[1] 1.070422 2.155585
var(x)
         [,1]     [,2]
[1,] 3.884654 1.880146
[2,] 1.880146 2.791173
plot(x)
plot of chunk example-mvtnorm-dmvnorm-1

[Package mvtnorm version 1.1-3 Index]