Median Absolute Deviation Aggregation Usage

edit

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|).

Fluent DSL example

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

Object Initializer syntax example

edit
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 Responses

edit
response.ShouldBeValid();
var medianAbsoluteDeviation = response.Aggregations.MedianAbsoluteDeviation("commit_variability");
medianAbsoluteDeviation.Should().NotBeNull();
medianAbsoluteDeviation.Value.Should().BeGreaterThan(0);