# MAHALANOBIS

## Description

The Mahalanobis function measures the distances of the cross-sectional point estimates from its empirical distribution. This is a multi-dimensional generalization tool in statistics. It is unitless, scale-invariant, and accounts for the correlation relationships within the data set.

For a given dataset,$$X$$, the Mahalanobis distance,$$D$$, is given by&#x20;

$$
D\_t=(X\_t-\mu) \Sigma^{-1}(X\_t-\mu)'
$$

$$
D\_t=\text{Mahalanobis distance for cross-section } t\newline
X\_t=\text{vector of asset returns for period } t\newline
\mu=\text{sample average of historical asset returns}\newline
\Sigma=\text{sample covariance matrix of asset returns}
$$

## Syntax

The following describes the function signature for use in Microsoft Excel's formula bar.

```excel-formula
=MAHALANOBIS(X, mu, covariance)
```

### Input(s)

<table><thead><tr><th width="150">Argument</th><th width="485.65217391304344">Description</th></tr></thead><tbody><tr><td><strong>X</strong></td><td>Matrix of time series returns (or values).</td></tr><tr><td><strong>mu</strong></td><td>Optional. Vector of means to measure the distance from. If the argument is not specified, it defaults to the sample average of the <strong>X</strong>.</td></tr><tr><td><strong>covariance</strong></td><td>Optional. Covariance matrix, specify a covariance matrix to normalize the distances. If the argument is not specified, it defaults to the sample covariance matrix of <strong>X</strong>.</td></tr></tbody></table>

### Output(s)

Vector of Mahalanobis distance values for the corresponding data, $$X$$. Vector will have the same length as $$X$$.

## Example

![](https://258561627-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK66-MGuoULhqCDXLwy%2F-ML9dRbWbwW2SVWdnYpe%2F-ML9nbPdbg6SDVajlh8J%2Fimage.png?alt=media\&token=9c7c896d-11ee-42ac-b238-ffce8f8fa2bb)

{% file src="<https://258561627-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK66-MGuoULhqCDXLwy%2F-MQVC6qUEDTtxolmHdXn%2F-ML9nw7N3O1nehODTWjB%2FTURBULENTRISK.xlsx?alt=media&token=ee8f4b23-d3e1-4a02-bf2c-ef6218f18037>" %}
Example Workbook
{% endfile %}
