0
$\begingroup$

Currently going through my Lecturer's notes and came across the Mahalanobis distance but nothing in the notes on how to work this out and googling hasn't really turned up anything either. My maths isn't great but I've been at it for 20 minutes now trying to come up with the same answer and can't.

The Mahalanobis norm is defined by $D_M^2(x) = (x-\mu)^T C^{-1}(x-\mu)$, and for my calculation, I have $(x-\mu)^T = [-90, -100]$ with covariance matrix

$C=\begin{pmatrix} 0.00025 & -0.00015 \\ -0.00015 & 0.00025 \end{pmatrix}$

Thanks in advance for your help.

  • 0
    I get a negative answer from your vectors (but your covariance matrix is indeed positive-definite); are you sure you computed $\mathbf x-\mu$ correctly?2011-05-16
  • 0
    Yes... the figures are from the lecture notes. (x-m)^T is the vector transposed, and they're -90 and -100 respectively2011-05-16
  • 0
    @J.M. If the matrix is positive definite, then there is no way to get a negative answer, regardless of what $x-\mu$ is. Every positive definite matrix gives rise to a positive definite bilinear form, by $B(x,y)=x^T A y$, (and in the finite dimensional case, every positive definite bilinear form comes from such a matrix).2011-05-16
  • 0
    Yes, that was an error @Aaron; I misread the vectors. I'm getting a Mahalanobis distance of $4250\sqrt{10}\approx 1.34397\times 10^4$.2011-05-16

2 Answers 2

1

Plugging in, we have $C^{-1}=\begin{pmatrix} 6250 & 3750 \\ 3750 & 6250 \end{pmatrix}$, and so $D_M^2= \begin{pmatrix}-90 & -100 \end{pmatrix}\begin{pmatrix} 6250 & 3750 \\ 3750 & 6250 \end{pmatrix} \begin{pmatrix}-90 \\ -100\end{pmatrix}=1.80625*10^8.$ Taking square roots, we see that the norm of $x$ is approximately $13439.7$.

  • 0
    Thanks. I got 1.825. We're not required to normalise x and the matrix was already inverted I should've been more specific with my notation.2011-05-16
0

I found myself factorising things to make the computation easier.

We have $x-\mu=-10[9\ 10]^T$ and $C=0.00005\begin{bmatrix}5&-3\\-3&5\end{bmatrix}$. So $C^{-1}=0.00005^{-1}\times \frac1{16}\begin{bmatrix}5&3\\3&5\end{bmatrix}$ and so $$(x-\mu)^TC^{-1}(x-\mu)= 0.00005^{-1} \times 1/16 \times (-10) \times (-10) \times [9\ 10]\begin{bmatrix}5&3\\3&5\end{bmatrix}\begin{bmatrix}9\\10\end{bmatrix}=125000 \times [9\ 10]\begin{bmatrix}75\\77\end{bmatrix}=125000 \times 1445=180625000.$$ So $D=\sqrt{180625000}\approx 13440$.

[Maybe you should look up matrix multiplication and inversion of $2\times 2$ matrices, since that's all that's going on here].

  • 0
    You forgot to invert $C$.2011-05-16
  • 0
    Thanks! Since I couldn't see how to delete my answer, I fixed it. (I hope.)2011-05-16
  • 0
    More exactly(?) $ D = \sqrt {180625000} = 4250 * \sqrt {10} $2011-05-26