(values: Iterable<number>)
| 265 | * returned: skewness and kurtosis do not change when all the deviations are |
| 266 | * multiplied by the same factor. The unit is a power of 2 near the largest |
| 267 | * deviation seen, so each scaled deviation is at most 1 in magnitude, and |
| 268 | * no power of a deviation overflows or underflows. Without this, the cube |
| 269 | * of the deviations of `[5·10¹⁰², −5·10¹⁰²]` overflows and the skewness is |
| 270 | * `NaN`, not `0`. When a larger deviation comes, the sums are converted to |
| 271 | * the new unit. A multiplication by a power of 2 is exact, so the unit does |
| 272 | * not add a rounding error. |
| 273 | */ |
| 274 | function centralMoments( |
| 275 | values: Iterable<number> |
| 276 | ): { n: number; m2: number; m3: number; m4: number } | undefined { |
| 277 | let n = 0; |
| 278 | let origin = 0; |
| 279 | // The exponent of the unit of the sums, or `undefined` while every |
| 280 | // deviation from the origin is zero (the sums are then zero). |
| 281 | let unit: number | undefined; |
no test coverage detected