In statistics, the **median absolute deviation (MAD)** is a robust measure of the variability of a univariate sample of quantitative data. It can also refer to the population parameter that is estimated by the MAD calculated from a sample.

For a univariate data set *X*_{1}, *X*_{2}, …, *X _{n}*, the MAD is defined as the median of the absolute deviations from the data’s median:

that is, starting with the residuals (deviations) from the data’s median, the MAD is the median of their absolute values.

**Source: Wikipedia**

As described in my previous post Standard Deviation, MAD is mostly used to overcome the outlier effect on sample population. It is a robust statistic, being more resilient to outliers in a data set than the standard deviation. In the standard deviation, the distances from the mean are squared, so large deviations are weighted more heavily, and thus outliers can heavily influence it. In the MAD, the deviations of a small number of outliers are irrelevant.

Example:

### q Solution

q)d:3 5 5 6 6 6 8 90 q)mad:{med abs d-med[x] } q)mad d 1f q)stdevExcel:{c:count x; (dev x)*sqrt c%c-1 } q)stdevExcel d 29.88281 q)dev d 27.95281