### 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
private static final int MIN_SAMPLE_VALUE = -1000000;
    private static final int MAX_SAMPLE_VALUE = 1000000;
    private static final int NUMBER_OF_DOCS = 1000;
    private static final Supplier<Long> sampleSupplier = () -> randomLongBetween(MIN_SAMPLE_VALUE, MAX_SAMPLE_VALUE);
    private static long[] singleValueSample;
    private static long[] multiValueSample;
    private static double singleValueExactMAD;
    private static double multiValueExactMAD;
    @Override
    public void setupSuiteScopeCluster() throws Exception {
        createIndex("idx", 1, 0);
        createIndex("idx_unmapped", 1, 0);
        minValue = MIN_SAMPLE_VALUE;
        minValues = MIN_SAMPLE_VALUE;
        maxValue = MAX_SAMPLE_VALUE;
        maxValues = MAX_SAMPLE_VALUE;
        singleValueSample = new long[NUMBER_OF_DOCS];
        multiValueSample = new long[NUMBER_OF_DOCS * 2];
        List<IndexRequestBuilder> builders = new ArrayList<>();
        for (int i = 0; i < NUMBER_OF_DOCS; i++) {
            final long singleValueDatapoint = sampleSupplier.get();
            final long firstMultiValueDatapoint = sampleSupplier.get();
            final long secondMultiValueDatapoint = sampleSupplier.get();
            singleValueSample[i] = singleValueDatapoint;
            multiValueSample[i * 2] = firstMultiValueDatapoint;
            multiValueSample[(i * 2) + 1] = secondMultiValueDatapoint;