ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Permutations.php
Go to the documentation of this file.
1<?php
2
4
9
11{
26 public static function PERMUT($numObjs, $numInSet)
27 {
28 $numObjs = Functions::flattenSingleValue($numObjs);
29 $numInSet = Functions::flattenSingleValue($numInSet);
30
31 try {
32 $numObjs = StatisticalValidations::validateInt($numObjs);
33 $numInSet = StatisticalValidations::validateInt($numInSet);
34 } catch (Exception $e) {
35 return $e->getMessage();
36 }
37
38 if ($numObjs < $numInSet) {
39 return Functions::NAN();
40 }
41 $result = round(MathTrig\Factorial::fact($numObjs) / MathTrig\Factorial::fact($numObjs - $numInSet));
42
44 }
45
57 public static function PERMUTATIONA($numObjs, $numInSet)
58 {
59 $numObjs = Functions::flattenSingleValue($numObjs);
60 $numInSet = Functions::flattenSingleValue($numInSet);
61
62 try {
63 $numObjs = StatisticalValidations::validateInt($numObjs);
64 $numInSet = StatisticalValidations::validateInt($numInSet);
65 } catch (Exception $e) {
66 return $e->getMessage();
67 }
68
69 if ($numObjs < 0 || $numInSet < 0) {
70 return Functions::NAN();
71 }
72
73 $result = $numObjs ** $numInSet;
74
76 }
77}
$result
An exception for terminatinating execution or to throw for unit testing.
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.
Definition: Functions.php:649
static PERMUTATIONA($numObjs, $numInSet)
PERMUTATIONA.
static evaluate($value)
Help some functions with large results operate correctly on 32-bit, by returning result as int when p...
Definition: IntOrFloat.php:15