From b836124d7c308d126d750b6ffec9274593bb16d2 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 15 Nov 2021 10:42:07 +0000 Subject: [PATCH 1/3] Special case NaNs in all statistical functions --- .../statistical_functions.md | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/spec/API_specification/statistical_functions.md b/spec/API_specification/statistical_functions.md index debccc185..df9c7d44a 100644 --- a/spec/API_specification/statistical_functions.md +++ b/spec/API_specification/statistical_functions.md @@ -24,6 +24,12 @@ Calculates the maximum value of the input array `x`. 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`). ``` +#### Special Cases + +Let `x_i` be an element over which to compute the maximum value. For floating-point operands, + +- if `x_i` is `NaN`, the maximum value is `NaN` (i.e., `NaN` values propagate). + #### Parameters - **x**: _<array>_ @@ -55,6 +61,11 @@ For a floating-point input array `x`, let `N` equal the number of elements over - if `N` is `0`, the arithmetic mean is `NaN`. +Let `x_i` be an element over which to compute the arithmetic mean. For floating-point operands, + +- if `x_i` is `NaN`, the arithmetic mean is `NaN` (i.e., `NaN` values propagate). + + #### Parameters - **x**: _<array>_ @@ -88,6 +99,12 @@ Calculates the minimum value of the input array `x`. 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`). ``` +#### Special Cases + +Let `x_i` be an element over which to compute the minimum value. For floating-point operands, + +- if `x_i` is `NaN`, the minimum value is `NaN` (i.e., `NaN` values propagate). + #### Parameters - **x**: _<array>_ @@ -119,6 +136,10 @@ For an input array `x`, let `N` equal the number of elements over which to compu - if `N` is `0`, the product is `1` (i.e., the empty product). +Let `x_i` be an element over which to compute the product. For floating-point operands, + +- if `x_i` is `NaN`, the product is `NaN` (i.e., `NaN` values propagate). + #### Parameters - **x**: _<array>_ @@ -163,6 +184,10 @@ For a floating-point input array `x`, let `N` equal the number of elements over - if `N - correction` is less than or equal to `0`, the standard deviation is `NaN`. +Let `x_i` be an element over which to compute the standard deviation. For floating-point operands, + +- if `x_i` is `NaN`, the standard deviation is `NaN` (i.e., `NaN` values propagate). + #### Parameters - **x**: _<array>_ @@ -202,6 +227,10 @@ For an input array `x`, let `N` equal the number of elements over which to compu - if `N` is `0`, the sum is `0` (i.e., the empty sum). +Let `x_i` be an element over which to compute the sum. For floating-point operands, + +- if `x_i` is `NaN`, the sum is `NaN` (i.e., `NaN` values propagate). + #### Parameters - **x**: _<array>_ @@ -246,6 +275,10 @@ For a floating-point input array `x`, let `N` equal the number of elements over - if `N - correction` is less than or equal to `0`, the variance is `NaN`. +Let `x_i` be an element over which to compute the variance. For floating-point operands, + +- if `x_i` is `NaN`, the variance is `NaN` (i.e., `NaN` values propagate). + #### Parameters - **x**: _<array>_ From 8a6053169a6ed3bae7a98f6d1af92583f3c916fa Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 6 Dec 2021 10:21:11 -0800 Subject: [PATCH 2/3] Update notes This commit brings the formatting and language in-line with element-wise and array object methods. --- .../statistical_functions.md | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/spec/API_specification/statistical_functions.md b/spec/API_specification/statistical_functions.md index df9c7d44a..4a372ff1e 100644 --- a/spec/API_specification/statistical_functions.md +++ b/spec/API_specification/statistical_functions.md @@ -26,7 +26,7 @@ When the number of elements over which to compute the maximum value is zero, the #### Special Cases -Let `x_i` be an element over which to compute the maximum value. For floating-point operands, +For floating-point operands, - if `x_i` is `NaN`, the maximum value is `NaN` (i.e., `NaN` values propagate). @@ -57,15 +57,11 @@ Calculates the arithmetic mean of the input array `x`. #### Special Cases -For a floating-point input array `x`, let `N` equal the number of elements over which to compute the arithmetic mean and +Let `N` equal the number of elements over which to compute the arithmetic mean. - if `N` is `0`, the arithmetic mean is `NaN`. - -Let `x_i` be an element over which to compute the arithmetic mean. For floating-point operands, - - if `x_i` is `NaN`, the arithmetic mean is `NaN` (i.e., `NaN` values propagate). - #### Parameters - **x**: _<array>_ @@ -101,7 +97,7 @@ When the number of elements over which to compute the minimum value is zero, the #### Special Cases -Let `x_i` be an element over which to compute the minimum value. For floating-point operands, +For floating-point operands, - if `x_i` is `NaN`, the minimum value is `NaN` (i.e., `NaN` values propagate). @@ -132,11 +128,11 @@ Calculates the product of input array `x` elements. #### Special Cases -For an input array `x`, let `N` equal the number of elements over which to compute the product and +Let `N` equal the number of elements over which to compute the product. - if `N` is `0`, the product is `1` (i.e., the empty product). -Let `x_i` be an element over which to compute the product. For floating-point operands, +For floating-point operands, - if `x_i` is `NaN`, the product is `NaN` (i.e., `NaN` values propagate). @@ -180,12 +176,9 @@ Calculates the standard deviation of the input array `x`. #### Special Cases -For a floating-point input array `x`, let `N` equal the number of elements over which to compute the standard deviation and - -- if `N - correction` is less than or equal to `0`, the standard deviation is `NaN`. - -Let `x_i` be an element over which to compute the standard deviation. For floating-point operands, +Let `N` equal the number of elements over which to compute the standard deviation. +- if `N - correction` is less than or equal to `0`, the standard deviation is `NaN`. - if `x_i` is `NaN`, the standard deviation is `NaN` (i.e., `NaN` values propagate). #### Parameters @@ -223,11 +216,11 @@ Calculates the sum of the input array `x`. #### Special Cases -For an input array `x`, let `N` equal the number of elements over which to compute the sum and +Let `N` equal the number of elements over which to compute the sum. - if `N` is `0`, the sum is `0` (i.e., the empty sum). -Let `x_i` be an element over which to compute the sum. For floating-point operands, +For floating-point operands, - if `x_i` is `NaN`, the sum is `NaN` (i.e., `NaN` values propagate). @@ -271,12 +264,9 @@ Calculates the variance of the input array `x`. #### Special Cases -For a floating-point input array `x`, let `N` equal the number of elements over which to compute the variance and - -- if `N - correction` is less than or equal to `0`, the variance is `NaN`. - -Let `x_i` be an element over which to compute the variance. For floating-point operands, +Let `N` equal the number of elements over which to compute the variance. +- if `N - correction` is less than or equal to `0`, the variance is `NaN`. - if `x_i` is `NaN`, the variance is `NaN` (i.e., `NaN` values propagate). #### Parameters From 73552fe8485d996ae256645ce187e1f27750333d Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 6 Dec 2021 10:25:37 -0800 Subject: [PATCH 3/3] Capitalize similar to element-wise and array object docs --- .../statistical_functions.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/API_specification/statistical_functions.md b/spec/API_specification/statistical_functions.md index 4a372ff1e..203ad10f6 100644 --- a/spec/API_specification/statistical_functions.md +++ b/spec/API_specification/statistical_functions.md @@ -28,7 +28,7 @@ When the number of elements over which to compute the maximum value is zero, the For floating-point operands, -- if `x_i` is `NaN`, the maximum value is `NaN` (i.e., `NaN` values propagate). +- If `x_i` is `NaN`, the maximum value is `NaN` (i.e., `NaN` values propagate). #### Parameters @@ -59,8 +59,8 @@ Calculates the arithmetic mean of the input array `x`. Let `N` equal the number of elements over which to compute the arithmetic mean. -- if `N` is `0`, the arithmetic mean is `NaN`. -- if `x_i` is `NaN`, the arithmetic mean is `NaN` (i.e., `NaN` values propagate). +- If `N` is `0`, the arithmetic mean is `NaN`. +- If `x_i` is `NaN`, the arithmetic mean is `NaN` (i.e., `NaN` values propagate). #### Parameters @@ -99,7 +99,7 @@ When the number of elements over which to compute the minimum value is zero, the For floating-point operands, -- if `x_i` is `NaN`, the minimum value is `NaN` (i.e., `NaN` values propagate). +- If `x_i` is `NaN`, the minimum value is `NaN` (i.e., `NaN` values propagate). #### Parameters @@ -130,11 +130,11 @@ Calculates the product of input array `x` elements. Let `N` equal the number of elements over which to compute the product. -- if `N` is `0`, the product is `1` (i.e., the empty product). +- If `N` is `0`, the product is `1` (i.e., the empty product). For floating-point operands, -- if `x_i` is `NaN`, the product is `NaN` (i.e., `NaN` values propagate). +- If `x_i` is `NaN`, the product is `NaN` (i.e., `NaN` values propagate). #### Parameters @@ -178,8 +178,8 @@ Calculates the standard deviation of the input array `x`. Let `N` equal the number of elements over which to compute the standard deviation. -- if `N - correction` is less than or equal to `0`, the standard deviation is `NaN`. -- if `x_i` is `NaN`, the standard deviation is `NaN` (i.e., `NaN` values propagate). +- If `N - correction` is less than or equal to `0`, the standard deviation is `NaN`. +- If `x_i` is `NaN`, the standard deviation is `NaN` (i.e., `NaN` values propagate). #### Parameters @@ -218,11 +218,11 @@ Calculates the sum of the input array `x`. Let `N` equal the number of elements over which to compute the sum. -- if `N` is `0`, the sum is `0` (i.e., the empty sum). +- If `N` is `0`, the sum is `0` (i.e., the empty sum). For floating-point operands, -- if `x_i` is `NaN`, the sum is `NaN` (i.e., `NaN` values propagate). +- If `x_i` is `NaN`, the sum is `NaN` (i.e., `NaN` values propagate). #### Parameters @@ -266,8 +266,8 @@ Calculates the variance of the input array `x`. Let `N` equal the number of elements over which to compute the variance. -- if `N - correction` is less than or equal to `0`, the variance is `NaN`. -- if `x_i` is `NaN`, the variance is `NaN` (i.e., `NaN` values propagate). +- If `N - correction` is less than or equal to `0`, the variance is `NaN`. +- If `x_i` is `NaN`, the variance is `NaN` (i.e., `NaN` values propagate). #### Parameters