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
+25-12
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Descriptive statistics
2
2
3
3
*[`mean` - mean of array elements](#mean---mean-of-array-elements)
4
-
*[`moment` - central moment of array elements](#moment---central-moment-of-array-elements)
4
+
*[`moment` - central moments of array elements](#moment---central-moments-of-array-elements)
5
5
*[`var` - variance of array elements](#var---variance-of-array-elements)
6
6
7
7
## `mean` - mean of array elements
@@ -48,12 +48,15 @@ program demo_mean
48
48
end program demo_mean
49
49
```
50
50
51
-
## `moment` - central moment of array elements
51
+
## `moment` - central moments of array elements
52
52
53
53
### Description
54
54
55
55
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`.
56
56
57
+
If a scalar or an array `center` is provided, the function returns the _k_-th order moment about 'center', 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`.
58
+
59
+
57
60
The _k_-th order central moment is defined as :
58
61
59
62
```
@@ -62,11 +65,17 @@ The _k_-th order central moment is defined as :
62
65
63
66
where n is the number of elements.
64
67
68
+
The _k_-th order moment about `center` is defined as :
69
+
70
+
```
71
+
moment(array) = 1/n sum_i (array(i) - center)^k
72
+
```
73
+
65
74
### Syntax
66
75
67
-
`result = moment(array, order [, mask])`
76
+
`result = moment(array, order [, center [, mask]])`
68
77
69
-
`result = moment(array, order, dim [, mask])`
78
+
`result = moment(array, order, dim [, center [, mask]])`
70
79
71
80
### Arguments
72
81
@@ -76,29 +85,33 @@ where n is the number of elements.
76
85
77
86
`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`.
78
87
88
+
`center` (optional): Shall be a scalar of the same type of `result` if `dim` is not provided. If `dim` is provided, `center` shall be a scalar or an array (with a shape similar to that of `array` with dimension `dim` dropped) of the same type of `result`.
89
+
79
90
`mask` (optional): Shall be of type `logical` and either by a scalar or an array of the same shape as `array`.
80
91
81
92
### Return value
82
93
83
94
If `array` is of type `real` or `complex`, the result is of the same type as `array`.
84
95
If `array` is of type `integer`, the result is of type `real(dp)`.
85
96
86
-
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.
97
+
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.
87
98
88
-
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`.
99
+
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