IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Median Absolute Deviation Aggregation Usage
editMedian Absolute Deviation Aggregation Usage
editA 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 example
edita => a .Average("average_commits", avg => avg .Field(p => p.NumberOfCommits) ) .MedianAbsoluteDeviation("commit_variability", m => m .Field(f => f.NumberOfCommits) )
Object Initializer syntax example
editnew 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
editresponse.ShouldBeValid(); var medianAbsoluteDeviation = response.Aggregations.MedianAbsoluteDeviation("commit_variability"); medianAbsoluteDeviation.Should().NotBeNull(); medianAbsoluteDeviation.Value.Should().BeGreaterThan(0);