|
| 1 | +using System.Runtime.Serialization; |
| 2 | +using Elasticsearch.Net; |
| 3 | + |
| 4 | +namespace Nest |
| 5 | +{ |
| 6 | + /// <summary> |
| 7 | + /// This single-value aggregation approximates the median absolute deviation of its search results. |
| 8 | + /// |
| 9 | + /// Median absolute deviation is a measure of variability. It is a robust statistic, meaning that |
| 10 | + /// it is useful for describing data that may have outliers, or may not be normally distributed. |
| 11 | + /// For such data it can be more descriptive than standard deviation. |
| 12 | + /// |
| 13 | + /// It is calculated as the median of each data point’s deviation from the median of the |
| 14 | + /// entire sample. That is, for a random variable <code>X</code>, the median absolute deviation |
| 15 | + /// is <code>median(|median(X) - Xi|).</code> |
| 16 | + /// </summary> |
| 17 | + [InterfaceDataContract] |
| 18 | + [ReadAs(typeof(MedianAbsoluteDeviationAggregation))] |
| 19 | + public interface IMedianAbsoluteDeviationAggregation : IMetricAggregation |
| 20 | + { |
| 21 | + /// <summary> |
| 22 | + /// TDigest algorithm component that controls memory usage and approximation error. |
| 23 | + /// By increasing the compression value, you can increase the accuracy |
| 24 | + /// at the cost of more memory. Larger compression values also make |
| 25 | + /// the algorithm slower since the underlying tree data structure grows in |
| 26 | + /// size, resulting in more expensive operations. The default compression value is <c>100</c>. |
| 27 | + /// </summary> |
| 28 | + [DataMember(Name = "compression")] |
| 29 | + double? Compression { get; set; } |
| 30 | + } |
| 31 | + |
| 32 | + /// <inheritdoc cref="IMedianAbsoluteDeviationAggregation"/> |
| 33 | + public class MedianAbsoluteDeviationAggregation : MetricAggregationBase, IMedianAbsoluteDeviationAggregation |
| 34 | + { |
| 35 | + internal MedianAbsoluteDeviationAggregation() { } |
| 36 | + |
| 37 | + public MedianAbsoluteDeviationAggregation(string name, Field field) : base(name, field) { } |
| 38 | + |
| 39 | + /// <inheritdoc /> |
| 40 | + public double? Compression { get; set; } |
| 41 | + |
| 42 | + internal override void WrapInContainer(AggregationContainer c) => c.MedianAbsoluteDeviation = this; |
| 43 | + } |
| 44 | + |
| 45 | + /// <inheritdoc cref="IMedianAbsoluteDeviationAggregation"/> |
| 46 | + public class MedianAbsoluteDeviationAggregationDescriptor<T> |
| 47 | + : MetricAggregationDescriptorBase<MedianAbsoluteDeviationAggregationDescriptor<T>, IMedianAbsoluteDeviationAggregation, T> |
| 48 | + , IMedianAbsoluteDeviationAggregation |
| 49 | + where T : class |
| 50 | + { |
| 51 | + double? IMedianAbsoluteDeviationAggregation.Compression { get; set; } |
| 52 | + |
| 53 | + /// <inheritdoc cref="IMedianAbsoluteDeviationAggregation.Compression"/> |
| 54 | + public MedianAbsoluteDeviationAggregationDescriptor<T> Compression(double? compression) => Assign(compression, (a, v) => a.Compression = v); |
| 55 | + } |
| 56 | +} |
0 commit comments