mahala: Mahalanobis distance

View source: R/mahala.R

Mahalanobis distanceR Documentation

Mahalanobis distance

Description

Mahalanobis distance.

Usage

mahala(x, mu, sigma, ischol = FALSE)

Arguments

x

A matrix with the data, where rows denotes observations (vectors) and the columns contain the variables.

mu

The mean vector.

sigma

The covariance or any square symmetric matrix.

ischol

A boolean variable set to true if the Cholesky decomposition of the covariance matrix is supplied in the argument \"sigma\".

Value

A vector with the Mahalanobis distances.

Author(s)

Matteo Fasiolo <matteo.fasiolo@gmail.com>,

C++ and R implementation and documentation: Matteo Fasiolo <matteo.fasiolo@gmail.com>.

See Also

dista, colmeans

Examples

x <- matrix( rnorm(100 * 50), ncol = 50 )
m <- colmeans(x)
s <- cov(x)
a1 <- mahala(x, m, s) 

Rfast documentation built on Nov. 9, 2023, 5:06 p.m.