函数名称:stats_stat_percentile()
适用版本:PHP 7.4.0 及以上版本
函数描述:stats_stat_percentile() 函数用于计算给定数组的百分位数。它基于 Stats PECL 扩展提供的统计函数。
用法:
float stats_stat_percentile ( array $arr, float $perc )
参数:
返回值:
示例:
$data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
// 计算第50个百分位数(中位数)
$median = stats_stat_percentile($data, 50);
echo "中位数:".$median; // 输出:5.5
// 计算第75个百分位数
$percentile75 = stats_stat_percentile($data, 75);
echo "第75个百分位数:".$percentile75; // 输出:8.25
注意事项: