# MEDIAN_ABSOLUTE_DEVIATION

Returns the median absolute deviation, a robust measure of variability. It is particularly useful for describing data with outliers or non-normal distributions, as it can be more descriptive than standard deviation. The median absolute deviation is calculated as the median of the absolute deviations from the median of the entire sample. For a random variable `X`, it is defined as `median(|median(X) - X|)`.

**Note:** This function is usually approximate, similar to `PERCENTILE`.

## Syntax

`MEDIAN_ABSOLUTE_DEVIATION(number)`

### Parameters

#### `number`

The input numeric field or expression.

## Examples

Basic Usage

```esql
FROM employees
| STATS MEDIAN(salary), MEDIAN_ABSOLUTE_DEVIATION(salary)
```

Calculate the median and the median absolute deviation of employee salaries.

Using Inline Functions

```esql
FROM employees
| STATS m_a_d_max_salary_change = MEDIAN_ABSOLUTE_DEVIATION(MV_MAX(salary_change))
```

Calculate the median absolute deviation of the maximum values of a multivalued column by first using `MV_MAX` to get the maximum value per row.

## Limitations

- `MEDIAN_ABSOLUTE_DEVIATION` is non-deterministic, meaning that slightly different results may be returned when using the same data.
