Differences Between: [Versions 400 and 402]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Calculation\Statistical; 4 5 use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled; 6 use PhpOffice\PhpSpreadsheet\Calculation\Exception; 7 use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; 8 9 class Standardize extends StatisticalValidations 10 { 11 use ArrayEnabled; 12 13 /** 14 * STANDARDIZE. 15 * 16 * Returns a normalized value from a distribution characterized by mean and standard_dev. 17 * 18 * @param array|float $value Value to normalize 19 * Or can be an array of values 20 * @param array|float $mean Mean Value 21 * Or can be an array of values 22 * @param array|float $stdDev Standard Deviation 23 * Or can be an array of values 24 * 25 * @return array|float|string Standardized value, or a string containing an error 26 * If an array of numbers is passed as an argument, then the returned result will also be an array 27 * with the same dimensions 28 */ 29 public static function execute($value, $mean, $stdDev) 30 { 31 if (is_array($value) || is_array($mean) || is_array($stdDev)) { 32 return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $mean, $stdDev); 33 } 34 35 try { 36 $value = self::validateFloat($value); 37 $mean = self::validateFloat($mean); 38 $stdDev = self::validateFloat($stdDev); 39 } catch (Exception $e) { 40 return $e->getMessage(); 41 } 42 43 if ($stdDev <= 0) { 44 return ExcelError::NAN(); 45 } 46 47 return ($value - $mean) / $stdDev; 48 } 49 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body