Skip to content

Commit b836124

Browse files
committed
Special case NaNs in all statistical functions
1 parent 4c041ea commit b836124

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

spec/API_specification/statistical_functions.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ Calculates the maximum value of the input array `x`.
2424
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`).
2525
```
2626

27+
#### Special Cases
28+
29+
Let `x_i` be an element over which to compute the maximum value. For floating-point operands,
30+
31+
- if `x_i` is `NaN`, the maximum value is `NaN` (i.e., `NaN` values propagate).
32+
2733
#### Parameters
2834

2935
- **x**: _<array>_
@@ -55,6 +61,11 @@ For a floating-point input array `x`, let `N` equal the number of elements over
5561

5662
- if `N` is `0`, the arithmetic mean is `NaN`.
5763

64+
Let `x_i` be an element over which to compute the arithmetic mean. For floating-point operands,
65+
66+
- if `x_i` is `NaN`, the arithmetic mean is `NaN` (i.e., `NaN` values propagate).
67+
68+
5869
#### Parameters
5970

6071
- **x**: _<array>_
@@ -88,6 +99,12 @@ Calculates the minimum value of the input array `x`.
8899
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`).
89100
```
90101

102+
#### Special Cases
103+
104+
Let `x_i` be an element over which to compute the minimum value. For floating-point operands,
105+
106+
- if `x_i` is `NaN`, the minimum value is `NaN` (i.e., `NaN` values propagate).
107+
91108
#### Parameters
92109

93110
- **x**: _<array>_
@@ -119,6 +136,10 @@ For an input array `x`, let `N` equal the number of elements over which to compu
119136

120137
- if `N` is `0`, the product is `1` (i.e., the empty product).
121138

139+
Let `x_i` be an element over which to compute the product. For floating-point operands,
140+
141+
- if `x_i` is `NaN`, the product is `NaN` (i.e., `NaN` values propagate).
142+
122143
#### Parameters
123144

124145
- **x**: _<array>_
@@ -163,6 +184,10 @@ For a floating-point input array `x`, let `N` equal the number of elements over
163184
164185
- if `N - correction` is less than or equal to `0`, the standard deviation is `NaN`.
165186
187+
Let `x_i` be an element over which to compute the standard deviation. For floating-point operands,
188+
189+
- if `x_i` is `NaN`, the standard deviation is `NaN` (i.e., `NaN` values propagate).
190+
166191
#### Parameters
167192
168193
- **x**: _<array>_
@@ -202,6 +227,10 @@ For an input array `x`, let `N` equal the number of elements over which to compu
202227
203228
- if `N` is `0`, the sum is `0` (i.e., the empty sum).
204229
230+
Let `x_i` be an element over which to compute the sum. For floating-point operands,
231+
232+
- if `x_i` is `NaN`, the sum is `NaN` (i.e., `NaN` values propagate).
233+
205234
#### Parameters
206235
207236
- **x**: _<array>_
@@ -246,6 +275,10 @@ For a floating-point input array `x`, let `N` equal the number of elements over
246275
247276
- if `N - correction` is less than or equal to `0`, the variance is `NaN`.
248277
278+
Let `x_i` be an element over which to compute the variance. For floating-point operands,
279+
280+
- if `x_i` is `NaN`, the variance is `NaN` (i.e., `NaN` values propagate).
281+
249282
#### Parameters
250283
251284
- **x**: _<array>_

0 commit comments

Comments
 (0)