1 |
|
2 |
|
3 | # Function mean
|
4 |
|
5 | Compute the mean value of matrix or a list with values.
|
6 | In case of a multi dimensional array, the mean of the flattened array
|
7 | will be calculated. When `dim` is provided, the maximum over the selected
|
8 | dimension will be calculated. Parameter `dim` is zero-based.
|
9 |
|
10 |
|
11 | ## Syntax
|
12 |
|
13 | ```js
|
14 | math.mean(a, b, c, ...)
|
15 | math.mean(A)
|
16 | math.mean(A, dim)
|
17 | ```
|
18 |
|
19 | ### Parameters
|
20 |
|
21 | Parameter | Type | Description
|
22 | --------- | ---- | -----------
|
23 | `args` | ... * | A single matrix or or multiple scalar values
|
24 |
|
25 | ### Returns
|
26 |
|
27 | Type | Description
|
28 | ---- | -----------
|
29 | * | The mean of all values
|
30 |
|
31 |
|
32 | ## Examples
|
33 |
|
34 | ```js
|
35 | math.mean(2, 1, 4, 3) // returns 2.5
|
36 | math.mean([1, 2.7, 3.2, 4]) // returns 2.725
|
37 |
|
38 | math.mean([[2, 5], [6, 3], [1, 7]], 0) // returns [3, 5]
|
39 | math.mean([[2, 5], [6, 3], [1, 7]], 1) // returns [3.5, 4.5, 4]
|
40 | ```
|
41 |
|
42 |
|
43 | ## See also
|
44 |
|
45 | [median](median.md),
|
46 | [min](min.md),
|
47 | [max](max.md),
|
48 | [sum](sum.md),
|
49 | [prod](prod.md),
|
50 | [std](std.md),
|
51 | [var](var.md)
|