You are here

public static function PHPExcel_Calculation_Statistical::PERMUT in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php \PHPExcel_Calculation_Statistical::PERMUT()

* PERMUT * * Returns the number of permutations for a given number of objects that can be * selected from number objects. A permutation is any set or subset of objects or * events where internal order is significant. Permutations are different from * combinations, for which the internal order is not significant. Use this function * for lottery-style probability calculations. * *

Parameters

int $numObjs Number of different objects: * @param int $numInSet Number of objects in each permutation * @return int Number of permutations

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php, line 2707

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

public static function PERMUT($numObjs, $numInSet) {
  $numObjs = PHPExcel_Calculation_Functions::flattenSingleValue($numObjs);
  $numInSet = PHPExcel_Calculation_Functions::flattenSingleValue($numInSet);
  if (is_numeric($numObjs) && is_numeric($numInSet)) {
    $numInSet = floor($numInSet);
    if ($numObjs < $numInSet) {
      return PHPExcel_Calculation_Functions::NaN();
    }
    return round(PHPExcel_Calculation_MathTrig::FACT($numObjs) / PHPExcel_Calculation_MathTrig::FACT($numObjs - $numInSet));
  }
  return PHPExcel_Calculation_Functions::VALUE();
}