mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices.
53 lines (35 loc) • 1.1 kB
Markdown
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.
```js
math.mean(a, b, c, ...)
math.mean(A)
math.mean(A, dim)
```
Parameter | Type | Description
--------- | ---- | -----------
`args` | ... * | A single matrix or or multiple scalar values
Type | Description
---- | -----------
* | The mean of all values
```js
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]
```
[](median.md),
[](min.md),
[](max.md),
[](sum.md),
[](prod.md),
[](std.md),
[](var.md)
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->