本文整理汇总了PHP中PHPExcel_Calculation_MathTrig::COMBIN方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Calculation_MathTrig::COMBIN方法的具体用法?PHP PHPExcel_Calculation_MathTrig::COMBIN怎么用?PHP PHPExcel_Calculation_MathTrig::COMBIN使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPExcel_Calculation_MathTrig
的用法示例。
在下文中一共展示了PHPExcel_Calculation_MathTrig::COMBIN方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: NEGBINOMDIST
/**
* NEGBINOMDIST
*
* Returns the negative binomial distribution. NEGBINOMDIST returns the probability that
* there will be number_f failures before the number_s-th success, when the constant
* probability of a success is probability_s. This function is similar to the binomial
* distribution, except that the number of successes is fixed, and the number of trials is
* variable. Like the binomial, trials are assumed to be independent.
*
* @param float $failures Number of Failures
* @param float $successes Threshold number of Successes
* @param float $probability Probability of success on each trial
* @return float
*
*/
public static function NEGBINOMDIST($failures, $successes, $probability)
{
$failures = floor(PHPExcel_Calculation_Functions::flattenSingleValue($failures));
$successes = floor(PHPExcel_Calculation_Functions::flattenSingleValue($successes));
$probability = PHPExcel_Calculation_Functions::flattenSingleValue($probability);
if (is_numeric($failures) && is_numeric($successes) && is_numeric($probability)) {
if ($failures < 0 || $successes < 1) {
return PHPExcel_Calculation_Functions::NaN();
}
if ($probability < 0 || $probability > 1) {
return PHPExcel_Calculation_Functions::NaN();
}
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
if ($failures + $successes - 1 <= 0) {
return PHPExcel_Calculation_Functions::NaN();
}
}
return PHPExcel_Calculation_MathTrig::COMBIN($failures + $successes - 1, $successes - 1) * pow($probability, $successes) * pow(1 - $probability, $failures);
}
return PHPExcel_Calculation_Functions::VALUE();
}