function getValueForAggregationMethod(values, aggregationMethod, assertionType) {
  if (aggregationMethod === 'median') {
    const medianIndex = Math.floor((values.length - 1) / 2);
    const sorted = values.slice().sort((a, b) => a - b);
    if (values.length % 2 === 1) return sorted[medianIndex];
    return (sorted[medianIndex] + sorted[medianIndex + 1]) / 2;
  }

  const useMin =
    (aggregationMethod === 'optimistic' && assertionType.startsWith('max')) ||
    (aggregationMethod === 'pessimistic' && assertionType.startsWith('min'));
  return useMin ? Math.min(...values) : Math.max(...values);
}
@param {number[]} values
@param {LHCI.AssertCommand.AssertionAggregationMethod} aggregationMethod
@param {LHCI.AssertResults.AssertionType} assertionType
@return {number}