public static function mean(array $values, ?int $n = null) : float
    {
        $n = $n ?? count($values);

        if ($n < 1) {
            throw new InvalidArgumentException('Mean is undefined for empty'
                . ' set.');
        }

        return array_sum($values) / $n;
    }
public static function mean(array $values, ?int $n = null) : float
    {
        $n = $n ?? count($values);

        if ($n < 1) {
            throw new InvalidArgumentException('Mean is undefined for empty'
                . ' set.');
        }

        return array_sum($values) / $n;
    }
public static function mean ( array $ values , ? int $ n = null ) : float { $ n = $ n ?? count ( $ values ) ; if ( $ n < 1 ) { throw new InvalidArgumentException ( 'Mean is undefined for empty' . ' set.' ) ; } return array_sum ( $ values ) / $ n ; }
Compute the population mean of a set of values.

@param array $values
@param int|null $n
@return float
Compute the population mean of a set of values .