# tablepress/3.4/libraries/vendor/PhpSpreadsheet/Calculation/Statistical/Standardize.php

TablePress – Tables in WordPress made easy, version 3.4. 50 lines.

- Page: https://pluginprobe.com/plugins/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/Calculation/Statistical/Standardize.php
- Raw: https://pluginprobe.com/plugins/tablepress/3.4/raw/libraries/vendor/PhpSpreadsheet/Calculation/Statistical/Standardize.php
- Modified: 2025-08-26T04:06:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/Calculation/Statistical/Standardize.php#L10-L20`.

```php
<?php

namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation\Statistical;

use TablePress\PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Exception;
use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;

class Standardize extends StatisticalValidations
{
	use ArrayEnabled;

	/**
	 * STANDARDIZE.
	 *
	 * Returns a normalized value from a distribution characterized by mean and standard_dev.
	 *
	 * @param array<mixed>|float $value Value to normalize
	 *                      Or can be an array of values
	 * @param array<mixed>|float $mean Mean Value
	 *                      Or can be an array of values
	 * @param array<mixed>|float $stdDev Standard Deviation
	 *                      Or can be an array of values
	 *
	 * @return array<mixed>|float|string Standardized value, or a string containing an error
	 *         If an array of numbers is passed as an argument, then the returned result will also be an array
	 *            with the same dimensions
	 */
	public static function execute($value, $mean, $stdDev)
	{
		if (is_array($value) || is_array($mean) || is_array($stdDev)) {
			return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $mean, $stdDev);
		}

		try {
			$value = self::validateFloat($value);
			$mean = self::validateFloat($mean);
			$stdDev = self::validateFloat($stdDev);
		} catch (Exception $e) {
			return $e->getMessage();
		}

		if ($stdDev <= 0) {
			return ExcelError::NAN();
		}

		return ($value - $mean) / $stdDev;
	}
}

```
