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
Special case when NaNs present in statistical functions (#335)
* Special case NaNs in all statistical functions
* Update notes
This commit brings the formatting and language in-line with element-wise and array object methods.
* Capitalize similar to element-wise and array object docs
Co-authored-by: Athan <kgryte@gmail.com>
Copy file name to clipboardExpand all lines: spec/API_specification/statistical_functions.md
+33-10Lines changed: 33 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,12 @@ Calculates the maximum value of the input array `x`.
24
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
25
```
26
26
27
+
#### Special Cases
28
+
29
+
For floating-point operands,
30
+
31
+
- If `x_i` is `NaN`, the maximum value is `NaN` (i.e., `NaN` values propagate).
32
+
27
33
#### Parameters
28
34
29
35
-**x**: _<array>_
@@ -51,9 +57,10 @@ Calculates the arithmetic mean of the input array `x`.
51
57
52
58
#### Special Cases
53
59
54
-
For a floating-point input array `x`, let `N` equal the number of elements over which to compute the arithmetic mean and
60
+
Let `N` equal the number of elements over which to compute the arithmetic mean.
55
61
56
-
- if `N` is `0`, the arithmetic mean is `NaN`.
62
+
- If `N` is `0`, the arithmetic mean is `NaN`.
63
+
- If `x_i` is `NaN`, the arithmetic mean is `NaN` (i.e., `NaN` values propagate).
57
64
58
65
#### Parameters
59
66
@@ -88,6 +95,12 @@ Calculates the minimum value of the input array `x`.
88
95
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
96
```
90
97
98
+
#### Special Cases
99
+
100
+
For floating-point operands,
101
+
102
+
- If `x_i` is `NaN`, the minimum value is `NaN` (i.e., `NaN` values propagate).
103
+
91
104
#### Parameters
92
105
93
106
-**x**: _<array>_
@@ -115,9 +128,13 @@ Calculates the product of input array `x` elements.
115
128
116
129
#### Special Cases
117
130
118
-
For an input array `x`, let `N` equal the number of elements over which to compute the product and
131
+
Let `N` equal the number of elements over which to compute the product.
132
+
133
+
- If `N` is `0`, the product is `1` (i.e., the empty product).
119
134
120
-
- if `N` is `0`, the product is `1` (i.e., the empty product).
135
+
For floating-point operands,
136
+
137
+
- If `x_i` is `NaN`, the product is `NaN` (i.e., `NaN` values propagate).
121
138
122
139
#### Parameters
123
140
@@ -161,9 +178,10 @@ Calculates the standard deviation of the input array `x`.
161
178
162
179
#### Special Cases
163
180
164
-
For a floating-point input array `x`, let `N` equal the number of elements over which to compute the standard deviation and
181
+
Let `N` equal the number of elements over which to compute the standard deviation.
165
182
166
-
- if `N - correction` is less than or equal to `0`, the standard deviation is `NaN`.
183
+
- If `N - correction` is less than or equal to `0`, the standard deviation is `NaN`.
184
+
- If `x_i` is `NaN`, the standard deviation is `NaN` (i.e., `NaN` values propagate).
167
185
168
186
#### Parameters
169
187
@@ -200,9 +218,13 @@ Calculates the sum of the input array `x`.
200
218
201
219
#### Special Cases
202
220
203
-
For an input array `x`, let `N` equal the number of elements over which to compute the sum and
221
+
Let `N` equal the number of elements over which to compute the sum.
222
+
223
+
- If `N` is `0`, the sum is `0` (i.e., the empty sum).
224
+
225
+
For floating-point operands,
204
226
205
-
- if `N` is `0`, the sum is `0` (i.e., the empty sum).
227
+
- If `x_i` is `NaN`, the sum is `NaN` (i.e., `NaN` values propagate).
206
228
207
229
#### Parameters
208
230
@@ -246,9 +268,10 @@ Calculates the variance of the input array `x`.
246
268
247
269
#### Special Cases
248
270
249
-
For a floating-point input array `x`, let `N` equal the number of elements over which to compute the variance and
271
+
Let `N` equal the number of elements over which to compute the variance.
250
272
251
-
- if `N - correction` is less than or equal to `0`, the variance is `NaN`.
273
+
- If `N - correction` is less than or equal to `0`, the variance is `NaN`.
274
+
- If `x_i` is `NaN`, the variance is `NaN` (i.e., `NaN` values propagate).
0 commit comments