### CI Link

https://gradle-enterprise.elastic.co/s/pwrwtjb2rq6p6/tests/:server:internalClusterTest/org.elasticsearch.search.aggregations.metrics.MedianAbsoluteDeviationIT/testAsSubAggregation?expanded-stacktrace=WyIwIl0&top-execution=1

### Repro line

./gradlew ':server:internalClusterTest' --tests "org.elasticsearch.search.aggregations.metrics.MedianAbsoluteDeviationIT.testAsSubAggregation" -Dtests.seed=949133CBE00FFB18 -Dtests.locale=uk -Dtests.timezone=Asia/Jakarta -Druntime.java=20

### Does it reproduce?

Yes

### Applicable branches

main

### Failure history

https://gradle-enterprise.elastic.co/scans/tests?search.startTimeMax=1689086155974&search.startTimeMin=1688418000000&search.timeZoneId=Europe/Bucharest&tests.container=org.elasticsearch.search.aggregations.metrics.MedianAbsoluteDeviationIT&tests.test=testAsSubAggregation

### Failure excerpt

Only failed once in the past 7 days.
```
java.lang.AssertionError: |  
  | Expected: within <10.0> percent of <273574.0> |  
  | but: was <229045.6480914681>
```

server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/metrics/MedianAbsoluteDeviationIT.java
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
import java.util.stream.LongStream;
import static java.util.Collections.emptyMap;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.search.aggregations.AggregationBuilders.filter;
import static org.elasticsearch.search.aggregations.AggregationBuilders.global;
import static org.elasticsearch.search.aggregations.AggregationBuilders.histogram;
import static org.elasticsearch.search.aggregations.AggregationBuilders.range;
import static org.elasticsearch.search.aggregations.AggregationBuilders.terms;
import static org.elasticsearch.search.aggregations.metrics.MedianAbsoluteDeviationAggregatorTests.ExactMedianAbsoluteDeviation.calculateMAD;
import static org.elasticsearch.search.aggregations.metrics.MedianAbsoluteDeviationAggregatorTests.IsCloseToRelative.closeToRelative;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.sameInstance;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
public class MedianAbsoluteDeviationIT extends AbstractNumericTestCase {