Median Absolute Deviation Aggregation Usageedit

A single-value aggregation that approximates the median absolute deviation of its search results.

Median absolute deviation is a measure of variability. It is a robust statistic, meaning that it is useful for describing data that may have outliers, or may not be normally distributed. For such data it can be more descriptive than standard deviation.

It is calculated as the median of each data point’s deviation from the median of the entire sample. That is, for a random variable X, the median absolute deviation is median(|median(X) - Xi|).

Be sure to read the Elasticsearch documentation on Median Absolute Deviation Aggregation

Fluent DSL exampleedit

a => a
.Average("average_commits", avg => avg
    .Field(p => p.NumberOfCommits)
.MedianAbsoluteDeviation("commit_variability", m => m
    .Field(f => f.NumberOfCommits)

Object Initializer syntax exampleedit

new AverageAggregation("average_commits", Infer.Field<Project>(p => p.NumberOfCommits)) &&
new MedianAbsoluteDeviationAggregation("commit_variability", Infer.Field<Project>(p => p.NumberOfCommits))

Example json output.

  "average_commits": {
    "avg": {
      "field": "numberOfCommits"
  "commit_variability": {
    "median_absolute_deviation": {
      "field": "numberOfCommits"

Handling Responsesedit

var medianAbsoluteDeviation = response.Aggregations.MedianAbsoluteDeviation("commit_variability");