> For the complete documentation index, see [llms.txt](https://excelhelp.windhamlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://excelhelp.windhamlabs.com/functions/scenario-analysis/mahalanobis.md).

# 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

![](/files/-ML9nbPdbg6SDVajlh8J)

{% file src="/files/-ML9nw7N3O1nehODTWjB" %}
Example Workbook
{% endfile %}
