mirror of
https://github.com/josdejong/mathjs.git
synced 2025-12-08 19:46:04 +00:00
1.1 KiB
1.1 KiB
Function mean
Compute the mean value of matrix or a list with values.
In case of a multi dimensional array, the mean of the flattened array
will be calculated. When dim is provided, the maximum over the selected
dimension will be calculated. Parameter dim is zero-based.
Syntax
math.mean(a, b, c, ...)
math.mean(A)
math.mean(A, dim)
Parameters
| Parameter | Type | Description |
|---|---|---|
args |
... * | A single matrix or or multiple scalar values |
Returns
| Type | Description |
|---|
- | The mean of all values
Examples
math.mean(2, 1, 4, 3) // returns 2.5
math.mean([1, 2.7, 3.2, 4]) // returns 2.725
math.mean([[2, 5], [6, 3], [1, 7]], 0) // returns [3, 5]
math.mean([[2, 5], [6, 3], [1, 7]], 1) // returns [3.5, 4.5, 4]