7

Is the Mahalanobis distance invariant with respect to arbitrary non-singular linear transformations? I mean if $C$ an arbitrary regular $(p × p)$-matrix and $b$ in $R$ arbitrary and $ \tilde{x}_n= C\,x_n +b$, is it then true that $d\left(x_n,x_m\right)=d\left(\tilde{x}_n,\tilde{x}_m\right)$. And if so, why?

Ernie060
  • 6,073
Rudi
  • 73

1 Answers1

7

Yes, the Mahalanobis distance is invariant under affine transformations. Intuitively this follows from the interpretation of the Mahalanobis distance. The Mahalanobis distance measures in a unitless and scale-invariant way how far an observation lies from the mean of the distribution. Another intuitive explanation can be found here.

Here is an explicit calculation.

Let $X$ be a random vector with expected value $\mu=E[X]$ and covariance matrix $S=E[(X-\mu)(X-\mu)^T]$. Consider the new random vector $\tilde X = C X + b$. Its expected value is $$ \tilde \mu = E[\tilde X] = E[CX + b] = C E[X] +b = C\mu + b. $$ Furthermore the covariance matrix $\tilde S$ of $\tilde X$ is $$ \begin{align*} \tilde S &= E[(\tilde X - \tilde \mu)(\tilde X - \tilde \mu)^T] \\ &= E[(CX +b-C\mu -b)(CX + b - C\mu- b)^T] \\ &= E[C(X-\mu)(X-\mu)^T C^T] \\ &= C E[(X-\mu)(X-\mu)^T]C^T = C S C^T. \end{align*} $$ Then the Mahalanobis distance between two observations $\tilde x = C x + b$ and $\tilde y = C y +b $ is the same as the Mahalanobis distance between $x$ and $y$: $$ \begin{align*} \left(d(\tilde x, \tilde y)\right)^2 &= (\tilde x - \tilde y)^T \tilde S^{-1} (\tilde x - \tilde y) \\ &= (x-y)^T C^T \left((C^T)^{-1}S^{-1}C^{-1}\right)\left(C(x-y)\right)\\ &= (x-y)^T S^{-1}(x-y) = \left(d(x, y)\right)^2. \end{align*} $$

Ernie060
  • 6,073
  • Thx now its totaly clear – Rudi Oct 07 '19 at 07:44
  • Amazing answer, so what is the difference compared to the question asked when we say that MD is equivariant method under non-singular transformation? – Avv Mar 27 '21 at 23:46
  • I see your comment quite late. I am not sure I interpret your question correctly. Do you mean the following: "How does the MD change under a transformation of the form $v\mapsto AvA^{-1}$, where $A$ is a constant matrix?" – Ernie060 Apr 12 '21 at 21:23