Exact Pearson r; `null` if a variance is zero (division by zero).
( ce: ComputeEngine, xs: Expression[], ys: Expression[] )
| 955 | return ce.function( |
| 956 | 'List', |
| 957 | counts.map((count, i) => |
| 958 | ce._fn('Tuple', [ce.number(binEdges[i]), ce.number(count)]) |
| 959 | ) |
| 960 | ); |
| 961 | }, |
| 962 | }, |
| 963 | |
| 964 | BinCounts: { |
| 965 | description: 'Count the number of elements falling into each bin.', |
| 966 | complexity: 8200, |
| 967 | // Same widened bin spec as Histogram (non-integer counts stay inert). |
| 968 | signature: '(collection<any>, number | list<number>) -> list<number>', |
| 969 | examples: ['BinCounts([1, 2, 2, 3], 3) // Returns [1, 2, 1]'], |
| 970 | // Decline-only, same `computeBinning` precondition as `Histogram`. |
| 971 | canEnumerate: canEnumerateFiniteSource, |
| 972 | evaluate: ([xs, binsArg], { engine: ce }) => { |
| 973 | const binning = computeBinning(xs, binsArg); |
| 974 | if (!binning) return undefined; |
| 975 | if (binning.rejected) |
| 976 | return dataConstraintError( |
| 977 | ce, |
| 978 | 'BinCounts', |
| 979 | binning.rejected.value, |
| 980 | binning.rejected.constraint |
| 981 | ); |
| 982 | |
| 983 | return ce.function( |
| 984 | 'List', |
| 985 | binning.counts.map((c) => ce.number(c)) |
| 986 | ); |
| 987 | }, |
| 988 | }, |
| 989 | |
| 990 | SlidingWindow: { |