# t-test as Mahalanobis distance

Our tutor once said that the t-test applies Mahalanobis distance. Could you please explain how it does so?

• I think a good answer to this question would also mention Hotelling's T-squared distribution, which in a sense generalises Student's t to multiple dimensions, which is the situation one normally encounters Mahalanobis distances. The relationship between the one-dimensional case and the univariate Student's t is pretty clear once we see them both as measuring "standard deviations from the mean". – Silverfish Dec 31 '14 at 19:10
• (That is very much a comment not an answer though - there's some subtleties about standard deviation of what? There is a link to PCA too - quick search for T squared, Mahalanobis and PCA produces some results which are at least tangentially relevant to the OP.) – Silverfish Jan 1 '15 at 12:39

Let $x,y$ be observations (matrices) from two $p$-dim multivariate distributions. Then the Mahalanobis distance is given by $$D_M^2 = (\bar{x}-\bar{y})^T S^{-1} (\bar{x}-\bar{y})$$ where $S$ is the sample covariance matrix. In the scalar case the $t$-statistic is given by $t^2 \propto \frac{(\bar{x}-\bar{y})^2}{\hat{\sigma}^2}$ which is (up to the scale factor I omitted) the same as the Mahalanobis distance for $S=(\hat{\sigma}^2)$.
The multivariate generalization of the $t$-statistic is the Hotelling $T$-squared given by $$T^2 = \frac{n_x n_y}{n_x+n_y}(\bar{x}-\bar{y})^T S^{-1} (\bar{x}-\bar{y})$$ which is proportional to the Mahalonibis distance. For more information, see https://en.wikipedia.org/wiki/Mahalanobis_distance and https://en.wikipedia.org/wiki/Hotelling%27s_T-squared_distribution.