dmnorm: Multivariate normal probability density

View source: R/dmnorm.R

dmnormR 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 dmnorm: Training data (n, p) used for estimating the mean and the covariance matrixhe population (if mu or/and sigma are not provided). For predict: New data (m, p) for which the density has to be predicted.

mu

The mean (p, 1) of the normal distribution. If NULL (default), mu is estimated by the column-wise mean of the training data.

sigma

The covariance matrix (p x p) of the normal distribution. If NULL (default), sigma is estimated by the empirical covariance matrix (denominator n - 1) of the training data.

object

A result of a call to dmnorm.

...

Optional arguments.

Value

See the examples.

Examples


data(iris)

X <- iris[, 1:2]

## Distribution of the class "Setosa"

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)


mlesnoff/rchemo documentation built on April 15, 2023, 1:25 p.m.