ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Gamma.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
8 class Gamma extends GammaBase
9 {
19  public static function gamma($value)
20  {
21  $value = Functions::flattenSingleValue($value);
22 
23  try {
25  } catch (Exception $e) {
26  return $e->getMessage();
27  }
28 
29  if ((((int) $value) == ((float) $value)) && $value <= 0.0) {
30  return Functions::NAN();
31  }
32 
33  return self::gammaValue($value);
34  }
35 
48  public static function distribution($value, $a, $b, $cumulative)
49  {
50  $value = Functions::flattenSingleValue($value);
53 
54  try {
58  $cumulative = DistributionValidations::validateBool($cumulative);
59  } catch (Exception $e) {
60  return $e->getMessage();
61  }
62 
63  if (($value < 0) || ($a <= 0) || ($b <= 0)) {
64  return Functions::NAN();
65  }
66 
67  return self::calculateDistribution($value, $a, $b, $cumulative);
68  }
69 
81  public static function inverse($probability, $alpha, $beta)
82  {
83  $probability = Functions::flattenSingleValue($probability);
84  $alpha = Functions::flattenSingleValue($alpha);
85  $beta = Functions::flattenSingleValue($beta);
86 
87  try {
88  $probability = DistributionValidations::validateProbability($probability);
91  } catch (Exception $e) {
92  return $e->getMessage();
93  }
94 
95  if (($alpha <= 0.0) || ($beta <= 0.0)) {
96  return Functions::NAN();
97  }
98 
99  return self::calculateInverse($probability, $alpha, $beta);
100  }
101 
111  public static function ln($value)
112  {
113  $value = Functions::flattenSingleValue($value);
114 
115  try {
117  } catch (Exception $e) {
118  return $e->getMessage();
119  }
120 
121  if ($value <= 0) {
122  return Functions::NAN();
123  }
124 
125  return log(self::gammaValue($value));
126  }
127 }
static inverse($probability, $alpha, $beta)
GAMMAINV.
Definition: Gamma.php:81
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.
Definition: Functions.php:649
static distribution($value, $a, $b, $cumulative)
GAMMADIST.
Definition: Gamma.php:48