/* SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. */ /* * Modifications Copyright OpenSearch Contributors. See * GitHub history for details. * * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ using System.Runtime.Serialization; using OpenSearch.Net.Utf8Json; namespace OpenSearch.Client { /// /// This single-value aggregation 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|). /// [InterfaceDataContract] [ReadAs(typeof(MedianAbsoluteDeviationAggregation))] public interface IMedianAbsoluteDeviationAggregation : IFormattableMetricAggregation { /// /// TDigest algorithm component that controls memory usage and approximation error. /// By increasing the compression value, you can increase the accuracy /// at the cost of more memory. Larger compression values also make /// the algorithm slower since the underlying tree data structure grows in /// size, resulting in more expensive operations. The default compression value is 100. /// [DataMember(Name = "compression")] double? Compression { get; set; } } /// public class MedianAbsoluteDeviationAggregation : FormattableMetricAggregationBase, IMedianAbsoluteDeviationAggregation { internal MedianAbsoluteDeviationAggregation() { } public MedianAbsoluteDeviationAggregation(string name, Field field) : base(name, field) { } /// public double? Compression { get; set; } internal override void WrapInContainer(AggregationContainer c) => c.MedianAbsoluteDeviation = this; } /// public class MedianAbsoluteDeviationAggregationDescriptor : FormattableMetricAggregationDescriptorBase, IMedianAbsoluteDeviationAggregation, T> , IMedianAbsoluteDeviationAggregation where T : class { double? IMedianAbsoluteDeviationAggregation.Compression { get; set; } /// public MedianAbsoluteDeviationAggregationDescriptor Compression(double? compression) => Assign(compression, (a, v) => a.Compression = v); } }