dmnorm {rchemo} | R Documentation |
Multivariate normal probability density
Description
Prediction of the normal probability density of multivariate observations.
Usage
dmnorm(X = NULL, mu = NULL, sigma = NULL)
## S3 method for class 'Dmnorm'
predict(object, X, ...)
Arguments
X |
For the main function: Training data ( |
mu |
The mean ( |
sigma |
The covariance matrix ( |
object |
For the auxiliary functions: A result of a call to |
... |
For the auxiliary functions: Optional arguments. |
Value
For dmnorm
:
mu |
means of the X variables |
Uinv |
inverse of the Cholesky decomposition of the covariance matrix |
det |
squared determinant of the Cholesky decomposition of the covariance matrix |
For predict
:
pred |
Prediction of the normal probability density of new multivariate observations |
Examples
data(iris)
X <- iris[, 1:2]
Xtrain <- X[1:40, ]
Xtest <- X[40:50, ]
fm <- dmnorm(Xtrain)
fm
k <- 50
x1 <- seq(min(Xtrain[, 1]), max(Xtrain[, 1]), length.out = k)
x2 <- seq(min(Xtrain[, 2]), max(Xtrain[, 2]), length.out = k)
zX <- expand.grid(x1, x2)
pred <- predict(fm, zX)$pred
contour(x1, x2, matrix(pred, nrow = 50))
points(Xtest, col = "red", pch = 16)