Oihana PHP

mean.php

Table of Contents

Functions

mean()  : float
Computes the arithmetic mean (average) of a list of numbers.

Functions

mean()

Computes the arithmetic mean (average) of a list of numbers.

mean(array<int, int|float> $values) : float
Parameters
$values : array<int, int|float>

A non-empty list of numeric values.

Tags
throws
InvalidArgumentException

If the array is empty.

example
use function oihana\core\maths\mean;

echo mean( [ 1 , 2 , 3 , 4 ] ) ; // 2.5
echo mean( [ 2 , 4 , 6 ] )      ; // 4.0
author

Marc Alcaraz (ekameleon)

since
1.0.9
Return values
float

The arithmetic mean of the values.

On this page

Search results