Formally, the Mahalanobis distance of a multivariate vector <math>x = ( x_1, x_2, x_3, dots, x_N )^T</math> from a group of values with mean <math>mu = ( mu_1, mu_2, mu_3, dots , mu_N )^T</math> and covariance matrix <math>S</math> is defined as:
<math>D_M(x) = sqrt., </math>
Mahalanobis distance (or "generalized squared interpoint distance" for its squared value) can also be defined as a dissimilarity measure between two random vectors <math> vec</math> and <math> vec</math> of the same distribution with the covariance matrix<math>S</math> :