Multivariate kansverdelingen in R
Surajit Ray
Professor, University of Glasgow


Normale dichtheid met $\mu=210$ en $\sigma=10$

Oppervlakte onder de curve voor $x < 200$
pnorm(200, mean = 210, sd = 10)
[1] 0.159


Wat is de $x_0$ zodat de cumulatieve kans bij $x_0$ 0,95 is?
qnorm( p = 0.95, mean = 210, sd = 10)
[1] 226.45
$\Rightarrow$ 95% van de koffiepotten heeft minder dan 226.45 gram koffie

Bivariate CDF bij x = 2 en y = 4 voor een normaalverdeling met ${\mu}={\begin{pmatrix} 1 \\ 2 \end{pmatrix}},\quad { \Sigma }={\begin{pmatrix} 1 & .5 \\ .5 & 2 \end{pmatrix}}$

Bivariate CDF bij x = 2 en y = 4 voor een normaalverdeling met ${\mu}={\begin{pmatrix} 1 \\ 2 \end{pmatrix}},\quad { \Sigma }={\begin{pmatrix} 1 & 0.5 \\ 0.5 & 2 \end{pmatrix}}$
mu1 <- c(1, 2)
sigma1 <- matrix(c(1, 0.5, 0.5, 2), 2)
pmvnorm(upper = c(2, 4), mean = mu1, sigma = sigma1)
[1] 0.79
attr(,"error")
[1] 1e-15
attr(,"msg")
[1] "Normal Completion"
Kans dat $ 1 < x <2$ en $2 < y < 4$
$$
pmvnorm(lower = c(1, 2),
upper = c(2, 4),
mean = mu1,
sigma = sigma1)

Kans dat $ 1 < x <2$ en $2 < y < 4$
$$
pmvnorm(lower = c(1, 2),
upper = c(2, 4),
mean = mu1,
sigma = sigma1)
[1] 0.163

Donkerrode ellips is de 0,95-kwantiel

sigma1 <- diag(2)
sigma1
[,1] [,2]
[1,] 1 0
[2,] 0 1
qmvnorm(p = 0.95, sigma = sigma1, tail = "both")
$quantile
[1] 2.24
$f.quantile
[1] -1.31e-06
attr(,"message")
[1] "Normal Completion"

De rode cirkel met straal 2,24 bevat 0,95 van de kans
Multivariate kansverdelingen in R