函数名称:stats_cdf_binomial()
适用版本:PHP 5 >= 5.3.0, PHP 7
函数描述:stats_cdf_binomial() 函数用于计算二项分布的累积分布函数(CDF)。
语法:float stats_cdf_binomial ( int $k , int $n , float $p , int $which )
参数:
- $k:要计算的二项分布的上限值。
- $n:二项分布的试验次数。
- $p:每次试验成功的概率。
- $which:指定要计算的分布函数。取值范围为 1(计算 P(X ≤ k))、2(计算 P(X < k))、3(计算 P(X ≥ k))和 4(计算 P(X > k))。
返回值:返回二项分布的累积分布函数的值。
示例:
// 计算 P(X ≤ 5),其中 n = 10,p = 0.3
$result = stats_cdf_binomial(5, 10, 0.3, 1);
echo "P(X ≤ 5) = " . $result . "\n";
// 计算 P(X < 3),其中 n = 8,p = 0.5
$result = stats_cdf_binomial(3, 8, 0.5, 2);
echo "P(X < 3) = " . $result . "\n";
// 计算 P(X ≥ 6),其中 n = 12,p = 0.2
$result = stats_cdf_binomial(6, 12, 0.2, 3);
echo "P(X ≥ 6) = " . $result . "\n";
// 计算 P(X > 4),其中 n = 6,p = 0.4
$result = stats_cdf_binomial(4, 6, 0.4, 4);
echo "P(X > 4) = " . $result . "\n";
输出:
P(X ≤ 5) = 0.84973166720352
P(X < 3) = 0.36328125
P(X ≥ 6) = 0.206439264
P(X > 4) = 0.39679999999999996
以上示例分别计算了不同条件下二项分布的累积分布函数的值,并将结果输出。注意,输入的参数可以根据实际情况进行调整。