You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/stdlib_experimental_stats.md
+12-6
Original file line number
Diff line number
Diff line change
@@ -8,36 +8,42 @@
8
8
9
9
### Description
10
10
11
-
Returns the mean of all the elements of `array`, or of the elements of `array` along dimension `dim` if provided.
11
+
Returns the mean of all the elements of `array`, or of the elements of `array` along dimension `dim` if provided, and if the corresponding element in `mask` is `true`.
12
12
13
13
### Syntax
14
14
15
-
`result = mean(array)`
15
+
`result = mean(array [, mask])`
16
16
17
-
`result = mean(array, dim)`
17
+
`result = mean(array, dim [, mask])`
18
18
19
19
### Arguments
20
20
21
21
`array`: Shall be an array of type `integer`, or `real`.
22
22
23
23
`dim`: Shall be a scalar of type `integer` with a value in the range from 1 to n, where n is the rank of `array`.
24
24
25
+
`mask` (optional): Shall be of type `logical` and either by a scalar or an array of the same shape as `array`.
26
+
25
27
### Return value
26
28
27
29
If `array` is of type `real`, the result is of the same type as `array`.
28
30
If `array` is of type `integer`, the result is of type `double precision`.
29
31
30
32
If `dim` is absent, a scalar with the mean of all elements in `array` is returned. Otherwise, an array of rank n-1, where n equals the rank of `array`, and a shape similar to that of `array` with dimension `dim` dropped is returned.
31
33
34
+
If `mask` is specified, the result is the mean of all elements of `array` corresponding to `true` elements of `mask`. If every element of `mask` is `false`, the result is IEEE `NaN`.
0 commit comments