Returns the average value of the current array.

@param int $decimals <p>The number of decimal-numbers to return.</p>

@return float|int
<p>The average value.</p>
11667
public function average($decimals = 0)
    {
        $count = \count($this->getArray(), \COUNT_NORMAL);

        if (!$count) {
            return 0;
        }

        if (!\is_int($decimals)) {
            $decimals = 0;
        }

        return \round(\array_sum($this->getArray()) / $count, $decimals);
    }
1204964
public function decimal($amount, $currency_code)
    {
        static $divisors = array();

        if (empty($divisors[$currency_code])) {
            $currency = $this->currency->get($currency_code);
            $divisors[$currency_code] = pow(10, $currency['decimals']);
        }

        return $amount / $divisors[$currency_code];
    }
526080
public function getAverage(ArrayCollection $ratings)
    {
        if ($ratings->count() === 0) {
            $average = 0;
        } else {
            $average = $this->getSum($ratings) / $ratings->count();
        }

        return $average;
    }
454624
public static double average(List<? extends Number> values) {
        if (values == null || values.isEmpty()) return 0D;

        double sum = 0D;
        for (Number v : values) sum += v.doubleValue();

        return sum / values.size();
    }
910699
public function average(){
		Number::setScale(static::NUMERIC_FUNCTIONS_SCALE);
		return Number::divide($this->sum(), \strval($this->count()));
	}
424678
public function andReturnValues(array $returnValues)
    {
        $this->andReturn(function() use (&$returnValues) {
            if (count($returnValues) > 1) {
                return array_shift($returnValues);
            } else {
                return current($returnValues);
            }
        });
        
        return $this;
    }
506369
public function toAll($decimals = null, $round = true)
    {
        if (!isset($this->value)) {
            throw new InvalidArgumentException('From value not set');
        }

        if (empty($this->base_unit)) {
            throw new InvalidArgumentException('No from unit set');
        }

        $units = array();

        foreach ($this->units as $key => $data) {
            if ($data['base'] == $this->base_unit) {
                array_push($units, $key);
            }
        }

        return $this->toMany($units, $decimals, $round);
    }
922249
protected function median($values) {
        $count = count($values);

        if ($count === 1) {
            return reset($values);
        }

        $middlevalue = (int)floor(($count - 1) / 2);

        if ($count % 2) {
            // Odd number, middle is the median.
            $median = $values[$middlevalue];
        } else {
            // Even number, calculate avg of 2 medians.
            $low = $values[$middlevalue];
            $high = $values[$middlevalue + 1];
            $median = (($low + $high) / 2);
        }
        return intval($median);
    }
1190198
public function stop($decimals = 3) : float
    {
        return (float) sprintf(
            '%0.'.(int) $decimals.'f',
            (microtime(true) - $this->startTime)
        );
    }
1258889
public function price($decimals = null, $decimalPoint = null, $thousandSeperator = null)
    {
        return $this->numberFormat($this->price, $decimals, $decimalPoint, $thousandSeperator);
    }
124177
public function getValues(array $digits)
    {
        $values = [];

        foreach ($digits as $digit) {
            $values[] = $this->digits->getValue($digit);
        }

        return $values;
    }
165905
public function readFloats($count)
    {
        $floats = array();

        for ($i = 0; $i < $count; $i++) {
            $float = $this->readFloat();

            if (! is_nan($float)) {
                $floats[] = $float;
            }
        }

        return $floats;
    }
478240
public function decimal($values, string $currency = null, int $decimal_points = 2): string
    {
        [$className, $value] = $this->classAndValue($values, $currency);

        return (new $className)->decimal($value, $decimal_points);
    }
868740
public static function average($array = false, $decimals = 2) {

        if($array && Validate::isArray($array)) {

            return self::round((array_sum($array) / count($array)), $decimals); 
        }

        return false;
    }
394607
public function subtotal($decimals = null, $decimalPoint = null, $thousandSeperator = null)
    {
        $content = $this->getContent();

        $subTotal = $content->reduce(function ($subTotal, CartItem $cartItem) {
            return $subTotal + ($cartItem->qty * $cartItem->price);
        }, 0);

        return $this->numberFormat($subTotal, $decimals, $decimalPoint, $thousandSeperator);
    }
614865
public static function sumColumnsWithAverages(array $entities, array $averages = array(), $precision = 2)
    {
        // Count the sum of all columns
        $sum = self::sumColumns($entities);

        if (!empty($averages)) {
            $count = count($entities);

            // Make sure that the division by zero won't occur
            if ($count === 0) {
                $count = 1;
            }

            foreach ($averages as $average) {
                if (isset($sum[$average])) {
                    if ($precision !== false) {
                    } else {
                        $sum[$average] = $sum[$average] / $count;
                    }
                    
                }
            }
        }

        return $sum;
    }
364804
public function get_decimals() {
        global $CFG;

        if (is_null($this->decimals)) {
            return grade_get_setting($this->courseid, 'decimalpoints', $CFG->grade_decimalpoints);

        } else {
            return $this->decimals;
        }
    }