### 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
final SearchResponse response = client().prepareSearch("idx")
            .setQuery(matchAllQuery())
            .addAggregation(
                randomBuilder().script(
                    new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value", Collections.emptyMap())
                )
            )
            .get();
        assertHitCount(response, NUMBER_OF_DOCS);
        final MedianAbsoluteDeviation mad = response.getAggregations().get("mad");
        assertThat(mad, notNullValue());
        assertThat(mad.getName(), is("mad"));
        assertThat(mad.getMedianAbsoluteDeviation(), closeToRelative(singleValueExactMAD));
    }
    @Override
    public void testScriptSingleValuedWithParams() throws Exception {
        final Map<String, Object> params = new HashMap<>();
        params.put("inc", 1);
        final SearchResponse response = client().prepareSearch("idx")
            .setQuery(matchAllQuery())
            .addAggregation(
                randomBuilder().script(new Script(ScriptType.INLINE, AggregationTestScriptsPlugin.NAME, "doc['value'].value + inc", params))
            )
            .get();
        assertHitCount(response, NUMBER_OF_DOCS);
        final MedianAbsoluteDeviation mad = response.getAggregations().get("mad");
        assertThat(mad, notNullValue());
        assertThat(mad.getName(), is("mad"));
        final double fromIncrementedSampleMAD = calculateMAD(Arrays.stream(singleValueSample).map(point -> point + 1).toArray());
        assertThat(mad.getMedianAbsoluteDeviation(), closeToRelative(fromIncrementedSampleMAD));