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
+58-3Lines changed: 58 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
## Implemented
4
4
5
5
*`mean`
6
+
*`moment`
6
7
*`var`
7
8
8
9
## `mean` - mean of array elements
@@ -28,7 +29,7 @@ Returns the mean of all the elements of `array`, or of the elements of `array` a
28
29
### Return value
29
30
30
31
If `array` is of type `real` or `complex`, the result is of the same type as `array`.
31
-
If `array` is of type `integer`, the result is of type `double precision`.
32
+
If `array` is of type `integer`, the result is of type `real(dp)`.
32
33
33
34
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.
34
35
@@ -49,6 +50,60 @@ program demo_mean
49
50
end program demo_mean
50
51
```
51
52
53
+
## `moment` - central moment of array elements
54
+
55
+
### Description
56
+
57
+
Returns the _k_-th order central moment 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`.
`array`: Shall be an array of type `integer`, `real`, or `complex`.
76
+
77
+
`order`: Shall be an scalar of type `integer`.
78
+
79
+
`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`.
80
+
81
+
`mask` (optional): Shall be of type `logical` and either by a scalar or an array of the same shape as `array`.
82
+
83
+
### Return value
84
+
85
+
If `array` is of type `real` or `complex`, the result is of the same type as `array`.
86
+
If `array` is of type `integer`, the result is of type `real(dp)`.
87
+
88
+
If `dim` is absent, a scalar with the _k_-th central moment 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.
89
+
90
+
If `mask` is specified, the result is the _k_-th central moment 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