public static function average($values)
    {
        $sum = array_sum($values);
        $count = count($values);

        // Avoid useless calculations
        if ($count == 0) {
            return 0;
        }

        return $sum / $count;
    }