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
Specify behavior of statistical reductions over the empty set (#262)
* Specify `mean` behavior when provided a 0D array
* Specify `prod` behavior when provided a 0D array
* Specify `sum` behavior when provided a 0D array
* Rephrase special cases and add special cases for other stats reductions
* Add guidance for min and max when `x` is 0D
Copy file name to clipboardExpand all lines: spec/API_specification/statistical_functions.md
+38
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,10 @@ A conforming implementation of the array API standard must provide and support t
20
20
21
21
Calculates the maximum value of the input array `x`.
22
22
23
+
```{note}
24
+
When the number of elements over which to compute the maximum value is zero, the maximum value is implementation-defined. Specification-compliant libraries may choose to error, return a sentinel value (e.g., if `x` is a floating-point input array, return `NaN`), or return the minimum possible value for the input array `x` data type (e.g., if `x` is a floating-point array, return `-infinity`).
25
+
```
26
+
23
27
#### Parameters
24
28
25
29
-**x**: _<array>_
@@ -45,6 +49,12 @@ Calculates the maximum value of the input array `x`.
45
49
46
50
Calculates the arithmetic mean of the input array `x`.
47
51
52
+
#### Special Cases
53
+
54
+
For a floating-point input array `x`, let `N` equal the number of elements over which to compute the arithmetic mean and
55
+
56
+
- if `N` is `0`, the arithmetic mean is `NaN`.
57
+
48
58
#### Parameters
49
59
50
60
-**x**: _<array>_
@@ -74,6 +84,10 @@ Calculates the arithmetic mean of the input array `x`.
74
84
75
85
Calculates the minimum value of the input array `x`.
76
86
87
+
```{note}
88
+
When the number of elements over which to compute the minimum value is zero, the minimum value is implementation-defined. Specification-compliant libraries may choose to error, return a sentinel value (e.g., if `x` is a floating-point input array, return `NaN`), or return the maximum possible value for the input array `x` data type (e.g., if `x` is a floating-point array, return `+infinity`).
89
+
```
90
+
77
91
#### Parameters
78
92
79
93
-**x**: _<array>_
@@ -99,6 +113,12 @@ Calculates the minimum value of the input array `x`.
99
113
100
114
Calculates the product of input array `x` elements.
101
115
116
+
#### Special Cases
117
+
118
+
For an input array `x`, let `N` equal the number of elements over which to compute the product and
119
+
120
+
- if `N` is `0`, the product is `1` (i.e., the empty product).
121
+
102
122
#### Parameters
103
123
104
124
-**x**: _<array>_
@@ -124,6 +144,12 @@ Calculates the product of input array `x` elements.
124
144
125
145
Calculates the standard deviation of the input array `x`.
126
146
147
+
#### Special Cases
148
+
149
+
For a floating-point input array `x`, let `N` equal the number of elements over which to compute the standard deviation and
150
+
151
+
- if `N - correction` is less than or equal to `0`, the standard deviation is `NaN`.
152
+
127
153
#### Parameters
128
154
129
155
-**x**: _<array>_
@@ -157,6 +183,12 @@ Calculates the standard deviation of the input array `x`.
157
183
158
184
Calculates the sum of the input array `x`.
159
185
186
+
#### Special Cases
187
+
188
+
For an input array `x`, let `N` equal the number of elements over which to compute the sum and
189
+
190
+
- if `N` is `0`, the sum is `0` (i.e., the empty sum).
191
+
160
192
#### Parameters
161
193
162
194
- **x**: _<array>_
@@ -182,6 +214,12 @@ Calculates the sum of the input array `x`.
182
214
183
215
Calculates the variance of the input array `x`.
184
216
217
+
#### Special Cases
218
+
219
+
For a floating-point input array `x`, let `N` equal the number of elements over which to compute the variance and
220
+
221
+
- if `N - correction` is less than or equal to `0`, the variance is `NaN`.
0 commit comments