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 F 10 { 11 use ArrayEnabled; 12 13 /** 14 * F.DIST. 15 * 16 * Returns the F probability distribution. 17 * You can use this function to determine whether two data sets have different degrees of diversity. 18 * For example, you can examine the test scores of men and women entering high school, and determine 19 * if the variability in the females is different from that found in the males. 20 * 21 * @param mixed $value Float value for which we want the probability 22 * Or can be an array of values 23 * @param mixed $u The numerator degrees of freedom as an integer 24 * Or can be an array of values 25 * @param mixed $v The denominator degrees of freedom as an integer 26 * Or can be an array of values 27 * @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false) 28 * Or can be an array of values 29 * 30 * @return array|float|string 31 * If an array of numbers is passed as an argument, then the returned result will also be an array 32 * with the same dimensions 33 */ 34 public static function distribution($value, $u, $v, $cumulative) 35 { 36 if (is_array($value) || is_array($u) || is_array($v) || is_array($cumulative)) { 37 return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $u, $v, $cumulative); 38 } 39 40 try { 41 $value = DistributionValidations::validateFloat($value); 42 $u = DistributionValidations::validateInt($u); 43 $v = DistributionValidations::validateInt($v); 44 $cumulative = DistributionValidations::validateBool($cumulative); 45 } catch (Exception $e) { 46 return $e->getMessage(); 47 } 48 49 if ($value < 0 || $u < 1 || $v < 1) { 50 return ExcelError::NAN(); 51 } 52 53 if ($cumulative) { 54 $adjustedValue = ($u * $value) / ($u * $value + $v); 55 56 return Beta::incompleteBeta($adjustedValue, $u / 2, $v / 2); 57 } 58 59 return (Gamma::gammaValue(($v + $u) / 2) / 60 (Gamma::gammaValue($u / 2) * Gamma::gammaValue($v / 2))) * 61 (($u / $v) ** ($u / 2)) * 62 (($value ** (($u - 2) / 2)) / ((1 + ($u / $v) * $value) ** (($u + $v) / 2))); 63 } 64 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body