

   MMaahhaallaannoobbiiss DDiissttaannccee

        mahalanobis(x, center, cov, inverted=FALSE)

   AArrgguummeennttss::

          x: vector or matrix of data with, say, p columns.

     center: mean vector of the distribution or second data
             vector of length p.

        cov: covariance matrix (p x p) of the distribution.

   inverted: logical.  If `TRUE', `cov' is supposed to contain
             the inverse of the covariance matrix.

   DDeessccrriippttiioonn::

        Returns the Mahalanobis distance of all rows in `x' and
        the vector mu=`center' with respect to ma=`cov'.  This
        is (for vector `x') defined as

                   D^2 = (x - mu)' ma^{-1} (x - mu)

   AAuutthhoorr((ss))::

        Friedrich Leisch

   SSeeee AAllssoo::

        `cov', `var'

   EExxaammpplleess::

        ma <- cbind(1:6, 1:3)
        (S <-  var(ma))
        mahalanobis(c(0,0), 1:2, S)

        x <- matrix(rnorm(100*3), ncol=3)
        all(mahalanobis(x, 0, diag(ncol(x)))
            == apply(x*x, 1,sum)) ##- Here, D^2 = usual Euclidean distances
        Sx <- cov(x)
        D2 <- mahalanobis(x, apply(x,2,mean), Sx)
        plot(density(D2))

