au.id.cxd.math.function.distance
mahalanobis distance between two vectors.
determine the distance from the mean using the variance covariance matrix of the supplied sample
distance between two matrices
a distance operation where the parameters Mu and Sigma have already been estimated.
after the distance calculation keep the full distance matrix.
Mahalanobis Distance An elliptical distance measure for the difference between two samples having the spread of their covariance matrix.
Given samples X and Y the Mahalanobis distance is given as
$$ dist(X,Y) = \left\{ (X-Y)' \Sigma_{X,Y}^{-1} (X-Y) \right\}^{1/2} $$ Where $\Sigma_{X,Y}^{-1}$ is the inverse of the variance-covariance matrix.
This bears a relationship to the shape and location of a multivariate normal distribution where the $Y$ sample in this case takes the place of the $\mu$ parameter for the mean of $X$ and the variance-covariance matrix is formed by the covariates of $X$.
This class supports distance calculations for
- The instance of two vectors $X$ and $Y$ the result is a single value
- The instance of two Matrices $X$ and $Y$ the result is a vector where each item is the distance of each row of X to each row of Y
- And in the case of a single matrix where the parameters $\mu$ and $\Sigma$ are estimated, where each item is the distance from X to the distribution parameters given or the parameters estimated from X, note in the case of the single matrix the resulting vector can then be sorted and plotted against the quartiles of the chi-squared distribution in order to define a qqplot, rendering a visualisation of the deviation from the expected quartile under the Multivariate normal assumption. This type of visualisation is useful in diagnosing whether a data set deviates from MVN.