查询

stats_cdf_t()函数—用法及示例

「 计算 Student's t 分布的累积分布函数(CDF),即给定自由度和 t 值,返回累积概率值 」


函数名:stats_cdf_t()

适用版本:PHP 5, PHP 7

函数说明:stats_cdf_t() 函数用于计算 Student's t 分布的累积分布函数(CDF),即给定自由度和 t 值,返回累积概率值。

语法:float stats_cdf_t ( float $par1, float $par2, int $which )

参数:

  • $par1: t 值
  • $par2: 自由度(degrees of freedom)
  • $which: 指定要计算的函数类型,取值范围为 1、2、3,分别表示累积分布函数(CDF)、补充累积分布函数(1 - CDF)和双尾概率(两边的概率之和)

返回值:计算得到的累积概率值

示例:

$tValue = 1.96;
$degreesOfFreedom = 10;
$cdf = stats_cdf_t($tValue, $degreesOfFreedom, 1);
echo "在自由度为{$degreesOfFreedom}的 t 分布中,t 值为{$tValue}的累积概率为:{$cdf}";

输出结果:

在自由度为10的 t 分布中,t 值为1.96的累积概率为:0.975

注意事项:

  • 该函数需要 stats 扩展支持,需要在 php.ini 中启用该扩展(extension=stats.so)
  • 自由度必须是正整数
  • 当 $which 参数为 1 或 2 时,返回值范围为 [0, 1]
  • 当 $which 参数为 3 时,返回值范围为 [0, 0.5]
补充纠错
上一个函数: stats_cdf_uniform()函数
下一个函数: stats_cdf_poisson()函数
热门PHP函数
分享链接