You are here

public static function PHPExcel_Calculation_MathTrig::MULTINOMIAL in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php \PHPExcel_Calculation_MathTrig::MULTINOMIAL()

* MULTINOMIAL * * Returns the ratio of the factorial of a sum of values to the product of factorials. * *

Parameters

array of mixed Data Series: * @return float

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php, line 712

Class

PHPExcel_Calculation_MathTrig
PHPExcel_Calculation_MathTrig

Code

public static function MULTINOMIAL() {
  $summer = 0;
  $divisor = 1;

  // Loop through arguments
  foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) {

    // Is it a numeric value?
    if (is_numeric($arg)) {
      if ($arg < 1) {
        return PHPExcel_Calculation_Functions::NaN();
      }
      $summer += floor($arg);
      $divisor *= self::FACT($arg);
    }
    else {
      return PHPExcel_Calculation_Functions::VALUE();
    }
  }

  // Return
  if ($summer > 0) {
    $summer = self::FACT($summer);
    return $summer / $divisor;
  }
  return 0;
}