# Proportionality of Mahalanobis distance for Gaussian PDF

According to my notes a Gaussian PDF $f_x(x)$ with $x$ ~ $\mathcal{N}(\mu,C_X)$ is proportional to the following:

$$f_x(x) \propto exp\left(-\frac{1}{2}(x - m_x)^TC^{-1}_x(x-m_x) \right)$$

$$\propto exp \left(-\frac{1}{2}(x^T C^{-1}_x x - 2x^T C^{-1}_x m_x) \right)$$

My Problelm is that I don't know how to get this final result.

Trying to multiply everything I ended up with this:

$$exp\left(-\frac{1}{2}(x - m_x)^TC^{-1}_x(x-m_x) \right) = exp\left(-\frac{1}{2}(x^T C^{-1}_x x - m_x^T C^{-1}_x x - x^T C^{-1}_x m_x + m_x^T C^{-1}_x m_x \right)$$ I would like to understand how this is derived in order to understand how the mean of a Gaussian random variable is estimated using Bayes estimator.

• You're almost done. Just notice that expressions like $m_x^\prime C_x^{-1} x$ are numbers and therefore equal their transposes and that the last term does not depend on $x$.
– whuber
Commented Jul 20, 2016 at 20:02
• Thanks for the hints! Does the first hint really mean that $m_x^T C_x^{-1} x = (m_x^T C_x^{-1} x)^T = x^T C_x^{-1} m_x$?
– fjp
Commented Jul 20, 2016 at 20:23
• If you're not sure, work it out for, say, the $2\times 2$ case. Use some actual numbers. I think that exercise will make the whole thing obvious.
– whuber
Commented Jul 20, 2016 at 22:35

Thanks to whuber for the hints:

• Expressions like $m_x^T C_x^{-1} x$ are numbers and therefore equal their transposes:

e.g. 2x2 case:

$$m^T_x C^{−1}_x x = (m^T_x C^{−1}_x x)^T = x^T C^{−1,T}_x m_x$$

$$m^T_x C^{-1}_x x = \begin{pmatrix}m_1 & m_2\end{pmatrix}\begin{pmatrix} c_{11} & c_{12} \\ c_{21} & c_{22} \end{pmatrix} \begin{pmatrix} x_1 \\ x_2 \end{pmatrix} \\ = c_{11}x_1m_1+c_{12}x_2m_1+c_{21}x_1m_2+c_{22}x_2m_2 \\ = (m_x^T C_x^{-1} x)^T = x^T C_x^{-1,T} m_x = \begin{pmatrix}x_1 & x_2\end{pmatrix}\begin{pmatrix} c_{11} & c_{21} \\ c_{12} & c_{22} \end{pmatrix} \begin{pmatrix} m_1 \\ m_2 \end{pmatrix}$$

• The term $m_x^T C_x^{-1} m_x$ does not depend on $x$ and can therfore be neglected because of the proportionality $\propto$.

Therefore

$$exp\left(-\frac{1}{2}(x - m_x)^TC^{-1}_x(x-m_x) \right) = exp\left(-\frac{1}{2}(x^T C^{-1}_x x - m_x^T C^{-1}_x x - x^T C^{-1}_x m_x + m_x^T C^{-1}_x m_x \right) \\ \propto exp\left(-\frac{1}{2}(x^T C^{-1}_x x - x^T C^{-1}_x m_x - x^T C^{-1}_x m_x \right) \\ = exp\left(-\frac{1}{2}(x^T C^{-1}_x x - 2 x^T C^{-1}_x m_x \right)$$