See Release Notes
Long Term Support Release
Differences Between: [Versions 400 and 401]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions; 4 5 use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled; 6 use PhpOffice\PhpSpreadsheet\Calculation\Exception; 7 use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; 8 9 class Exponential 10 { 11 use ArrayEnabled; 12 13 /** 14 * EXPONDIST. 15 * 16 * Returns the exponential distribution. Use EXPONDIST to model the time between events, 17 * such as how long an automated bank teller takes to deliver cash. For example, you can 18 * use EXPONDIST to determine the probability that the process takes at most 1 minute. 19 * 20 * @param mixed $value Float value for which we want the probability 21 * Or can be an array of values 22 * @param mixed $lambda The parameter value as a float 23 * Or can be an array of values 24 * @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false) 25 * Or can be an array of values 26 * 27 * @return array|float|string 28 * If an array of numbers is passed as an argument, then the returned result will also be an array 29 * with the same dimensions 30 */ 31 public static function distribution($value, $lambda, $cumulative) 32 { 33 if (is_array($value) || is_array($lambda) || is_array($cumulative)) { 34 return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $lambda, $cumulative); 35 } 36 37 try { 38 $value = DistributionValidations::validateFloat($value); 39 $lambda = DistributionValidations::validateFloat($lambda); 40 $cumulative = DistributionValidations::validateBool($cumulative); 41 } catch (Exception $e) { 42 return $e->getMessage(); 43 } 44 45 if (($value < 0) || ($lambda < 0)) { 46 return ExcelError::NAN(); 47 } 48 49 if ($cumulative === true) { 50 return 1 - exp(0 - $value * $lambda); 51 } 52 53 return $lambda * exp(0 - $value * $lambda); 54 } 55 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body