median-absolute-deviation.asciidoc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. [discrete]
  2. [[esql-agg-median-absolute-deviation]]
  3. === `MEDIAN_ABSOLUTE_DEVIATION`
  4. *Syntax*
  5. [source,esql]
  6. ----
  7. MEDIAN_ABSOLUTE_DEVIATION(column)
  8. ----
  9. *Parameters*
  10. `column`::
  11. Column from which to return the median absolute deviation.
  12. *Description*
  13. Returns the median absolute deviation, a measure of variability. It is a robust
  14. statistic, meaning that it is useful for describing data that may have outliers,
  15. or may not be normally distributed. For such data it can be more descriptive
  16. than standard deviation.
  17. It is calculated as the median of each data point's deviation from the median of
  18. the entire sample. That is, for a random variable `X`, the median absolute
  19. deviation is `median(|median(X) - X|)`.
  20. NOTE: Like <<esql-agg-percentile>>, `MEDIAN_ABSOLUTE_DEVIATION` is
  21. <<esql-agg-percentile-approximate,usually approximate>>.
  22. [WARNING]
  23. ====
  24. `MEDIAN_ABSOLUTE_DEVIATION` is also {wikipedia}/Nondeterministic_algorithm[non-deterministic].
  25. This means you can get slightly different results using the same data.
  26. ====
  27. *Example*
  28. [source.merge.styled,esql]
  29. ----
  30. include::{esql-specs}/stats_percentile.csv-spec[tag=median-absolute-deviation]
  31. ----
  32. [%header.monospaced.styled,format=dsv,separator=|]
  33. |===
  34. include::{esql-specs}/stats_percentile.csv-spec[tag=median-absolute-deviation-result]
  35. |===