R: Mahalanobis distance

Mahalanobis distance {Rfast} | R 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)

[Package Rfast version 2.0.0 Index]