Return the statistical range given by the maximum minus the minimum
of a set of values.

@param array $values
@throws \InvalidArgumentException
@return float
970051
public static function range(array $values) : float
    {
        if (empty($values)) {
            throw new InvalidArgumentException('Range is undefined for empty'
                . ' set.');
        }

        return (float) (max($values) - min($values));
    }
1105412
protected function iterate($values)
    {
        if (!is_object($values) && !is_array($values)) {
            throw new \InvalidArgumentException("Unable to validate provided object");
        }
        $errors = [];
        foreach ($this->ruleset as $field => $rules) {
            $value = $this->access($values, $field);
            $error = $rules->apply($value, $values);
            if ($error !== null) {
                $errors[$field] = count($error) > 1 || count(array_filter(array_keys($error), 'is_string')) > 0 ?
                    $error : current($error);
            }
        }
        return $errors;
    }
501386
@Pure
	public static int max(int... values) {
		if (values == null || values.length == 0) {
			return 0;
		}
		int max = values[0];
		for (final int v : values) {
			if (v > max) {
				max = v;
			}
		}
		return max;
	}
883882
protected function aggregateValues(array $values)
    {
        $max = $values[0];

        foreach ($values as $value) {
            if ($value > $max) {
                $max = $value;
            }
        }

        return $max;
    }
316810
protected function getPreferredValue(array $values)
    {
        foreach ($values as $v) {
            if (!is_null($v) && !empty($v)) {
                return $v;
            }
        }

        return '';
    }
525284
private function validateCronRange($value, $min, $max)
    {
        if ($value === null || $value === '*') {
            return '*';
        }

        if (! is_numeric($value) ||
            ! ($value >= $min && $value <= $max)
        ) {
            throw new InvalidArgumentException(
                "Invalid value: it should be '*' or between {$min} and {$max}."
            );
        }

        return $value;
    }
504106
public function maxNorm(): float
    {
        return array_reduce($this->toArray(), function (float $carry, float $value) {
            $value = abs($value);

            return $carry > $value ? $carry : $value;
        }, -INF);
    }
1139178
protected function valPropValues(array $values)
    {
        $validPropertyValues = [];

        // Run through all property values
        /** @var ValueInterface $value */
        foreach ($values as $value) {
            $this->procPropValue($value, $validPropertyValues);
        }

        return $validPropertyValues;
    }
192971
public static function toInt($value)
    {
        if (!static::is($value)) {
            throw new \InvalidArgumentException(
                "The \$value parameter must be numeric (or string representing a big number)."
            );
        }

        if (is_int($value)) {
            return $value;
        } elseif (is_float($value)) {
            return (int)$value;
        }

        if (($decimal = Str::pos($value, '.')) !== false) {
            $value = Str::sub($value, 0, (int)$decimal);
        }

        return $value;
    }
558227
public function fit(array $values) : void
    {
        if (empty($values)) {
            throw new InvalidArgumentException('Strategy must be fit with'
                . ' at least 1 value.');
        }

        $this->mean = Stats::mean($values);
    }
105433
public static function average($values, $precision = 0) {
		if (empty($values)) {
			return 0.0;
		}
		return round(array_sum($values) / count($values), $precision);
	}
1202870
public static function toFloat($value)
    {
        if (!static::is($value)) {
            throw new \InvalidArgumentException(
                "The \$value parameter must be numeric (or string representing a big number)."
            );
        }

        if (is_int($value) || is_float($value)) {
            return (float)$value;
        } else {
            return ((Str::contains($value, '.')) ? $value : $value . '.0');
        }
    }
988235
public function values($values = null)
    {
        deprecationWarning(
            'ValuesExpression::values() is deprecated. ' .
            'Use ValuesExpression::setValues()/getValues() instead.'
        );
        if ($values !== null) {
            return $this->setValues($values);
        }

        return $this->getValues();
    }
1156416
public static function mad(array $values, ?float $median = null) : float
    {
        $median = $median ?? self::median($values);

        $deviations = [];

        foreach ($values as $value) {
            $deviations[] = abs($value - $median);
        }

        return self::median($deviations);
    }
1036365
protected function _validate_range($value, $parameter)
    {
        if (preg_match('#^(-?[\.\d]+)-(-?[\d\.]+)$#', $parameter, $match)) {
            return $value >= $match[1] && $value <= $match[2] ? $value : null;
        } else {
            throw new InvalidValueException(['range validator `:parameter` parameters is not {min}-{max} format', 'parameter' => $parameter]);
        }
    }
1362236
public static double min(final double[] values) {
		double min = NaN;
		if (values.length > 0) {
			min = values[0];

			for (int i = 0; i < values.length; ++i) {
				if (values[i] < min) {
					min = values[i];
				}
			}
		}

		return min;
	}
826823
public static function floats(float $min, float $max, int $n = 10) : array
    {
        if (($max - $min) < 0.) {
            throw new InvalidArgumentException('Maximum cannot be'
                . ' less than minimum.');
        }

        if ($n < 1) {
            throw new InvalidArgumentException('Cannot generate less'
                . ' than 1 parameter.');
        }

        $min = (int) round($min * self::PHI);
        $max = (int) round($max * self::PHI);

        $distribution = [];

        for ($i = 0; $i < $n; $i++) {
            $distribution[] = rand($min, $max) / self::PHI;
        }

        return $distribution;
    }