public static function iqr(array $values) : float
    {
        $n = count($values);

        if ($n < 1) {
            throw new InvalidArgumentException('Interquartile range is not'
                . ' defined for empty set.');
        }

        $mid = intdiv($n, 2);

        sort($values);

        if ($n % 2 === 0) {
            $lower = array_slice($values, 0, $mid);
            $upper = array_slice($values, $mid);
        } else {
            $lower = array_slice($values, 0, $mid);
            $upper = array_slice($values, $mid + 1);
        }

        return self::median($upper) - self::median($lower);
    }