public static function truncatedMean(array $numbers, int $trim_percent)
{
if ($trim_percent < 0 || $trim_percent > 99) {
throw new Exception\OutOfBoundsException('Trim percent must be between 0 and 99.');
}
$n = count($numbers);
$trim_count = floor($n * ($trim_percent / 100));
sort($numbers);
for ($i = 1; $i <= $trim_count; $i++) {
array_shift($numbers);
array_pop($numbers);
}
return self::mean($numbers);
}