chore: address review findings in new stats/incr/nan* packages#13602
chore: address review findings in new stats/incr/nan* packages#13602Planeshifter wants to merge 12 commits into
stats/incr/nan* packages#13602Conversation
…cr/nanmpcorrdist`
… `stats/incr/nanmmda`
…on in `stats/incr/nanmmpe`
stats/incr/nan* packagesstats/incr/nan* packages
Replaces EPS-relative tolerance checks with ULP-based comparisons via `@stdlib/assert/is-almost-same-value`. As the correlation distance is computed as `d = 1 - r`, floating-point error in `d` arises at the scale of ULPs of unity, so values are compared at unit scale (`1.0 + d`). The previous relative tolerances collapsed toward zero for near-zero distances (r ~ 1), causing seed-dependent failures in roughly one out of four runs (496/2000 simulated seeds; observed max drift of 54958 ULPs at unit scale, hence a 1e6 ULP budget matching the previous `1.0e6 * EPS` relative tolerance).
Coverage Report
The above coverage report was generated for the changes in this PR. |
This reverts commit 01ab576.
The correlation distance is computed as `d = 1 - r`, meaning floating-point error in `d` accumulates at the scale of ULPs of unity and is largely independent of the magnitude of `d` itself. For near-zero distances (r ~ 1; common when NaN-dense windows keep the effective sample size small), a relative tolerance is arbitrarily strict, causing seed-dependent failures in ~25% of simulated seeds (and matching failures observed on develop). An absolute tolerance of `1.0e6 * EPS` reuses the magnitude of the previous relative tolerance at O(1) distances and bounds the maximum observed error (2.5e-11 across 8000 simulated seeds) with ~10x headroom. All other tolerance logic matches `stats/incr/mpcorrdist`.
…g/equation_mean_error.svg
|
FYI: the coverage job failed again on 9cdfa8f — 3 assertions in the These are the tolerances restored by the discard of 306ca40. Under them, ~25% of seeds fail (simulated over 2000 seeds); the base Happy to reinstate the absolute-tolerance change (3-line diff, Generated by Claude Code |
Description
Follow-up fixes for commits merged to
developbetween b772009 (2026-07-20 13:08 -0700) and 729ff85 (2026-07-20 23:22 -0500).This pull request:
stats/incr/nanmpcorrdist: Fixedstats/incr/nanmpcorrdist(regression from 729ff85):lib/main.jsgated forwarding ofmx/myonarguments.length > 2, soincrnanmpcorrdist( W, mx )silently droppedmxinstead of forwarding toincrmpcorrdist, and the documentedTypeErrornever fired. Changed the condition toarguments.length > 1, matching the base accumulator andstats/incr/nanmpcorr.stats/incr/nanmpcorrdist: Fixed the flaky test tolerances intest/test.js(729ff85) that were failing seed-dependently ondevelopand on this PR's CI. The tolerance logic otherwise follows the basestats/incr/mpcorrdisttests, with one deviation: the random-sweep test now uses an absolute tolerance of1.0e6 * EPSinstead of1.0e6 * EPS * |expected|with a10 * EPSzero-guard. Rationale:d = 1 - r, so floating-point error indaccumulates at the scale of ULPs of unity and is largely independent of|d|; nearr ≈ 1(common when NaN-dense windows keep the effective sample size small), a relative tolerance is arbitrarily strict. Validation: the old assertions failed on ~25% of 2000 simulated seeds; the maximum observed error across 8000 seeds is 2.5e-11 (the new tolerance is ~10x above it); 300 full-suite runs under fresh random seeds pass cleanly. An initial ULP-based rewrite (isAlmostSameValueat unit anchor) was pushed and then reverted in favor of matching the base package's test style.stats/incr/nanmpcorr2: Fixincrnanmpcorr2's two-argmeanx-only call: 026b97a gated forwarding to the baseincrmpcorr2constructor onarguments.length > 2inlib/main.js, someanxwas silently dropped instead of surfacing the base'sTypeErrorfor a missingmeany. Changed the condition toarguments.length > 1, matchingincrmpcorr2and thenanmpcorrsibling wrapper.stats/incr/nanewmean: Fixed a copy-paste leftover from theewmeanREADME: the commented-out equation imagesrcinstats/incr/nanewmean/README.mdstill pointed atstats/incr/ewmean/docs/img/...instead of its owndocs/img, whereequation_exponentially_weighted_mean.svgactually lives. Repointed it tostats/incr/nanewmean/docs/img/..., consistent with hownanewstdevself-references (1356c75).stats/incr/nanmmda: Fix path in README (43eb423): the commented-out equation imagesrcpointed atstats/incr/mmda/docs/img/...instead ofstats/incr/nanmmda/docs/img/..., same copy-paste slip asnanewmean— now points at the package's ownequation_mean_directional_accuracy.svg.stats/incr/nanmme: Fixstats/incr/nanmme:docs/img/equation_mean_error.svglanded empty (0 bytes) in e6abaec. Populated it with the rendered SVG fromstats/incr/mme/docs/img/equation_mean_error.svg(8694 bytes), matching hownanmpe/nanmmpe/nanmmdamirror their base packages.stats/incr/nanmmpe: Fixedstats/incr/nanmmpe's.d.tsin 19d792a — it dropped the@stdlib/typestriple-slash reference directive after// TypeScript Version: 4.1that every other nan-wrapper sibling from that commit carries. Restored it indocs/types/index.d.tsto matchstats/incr/mmpeand its siblings.stats/incr/nanmmda,stats/incr/nanmmpe: Fixed erroneous Markdown backticks aroundNaNin thedescriptionfields of both packages'package.json(43eb423, 19d792a); package.json descriptions aren't rendered as Markdown, and no otherstats/incrpackage quotes it that way.Related Issues
No.
Questions
Simulation shows the base
stats/incr/mpcorrdisttest carries the same flaw: under its own tolerances and NaN-free datasets, it fails on 1134/5000 simulated seeds (~23%) — it just runs rarely, as tests only execute when the package changes. The same relative-tolerance pattern (without even a zero-guard) exists instats/incr/nanmpcorr2/mpcorr2, though the known-means/r²paths were empirically stable in 2000-seed simulation. Recommend applying the same absolute-tolerance fix family-wide in a follow-up.Other
Validation performed on all 26 commits merged to
developin the 24-hour window (b772009…729ff85):stats/incr/nan*accumulator packages,blas/asum,blas/ext/base/zxdy+ ndarray variant, themath/base/special/sindULP test migration) againstdocs/style-guidesand established reference packages.constants/float64/nanC refactor (b953edd) is a semantics-preserving literal-to-constant swap (146↔146 balanced across 99 source files with matching include/manifest updates), that theblas/asumdtype dispatch table is correct, and that thezxdycomplex-division loops handle strides/offsets correctly.TypeErroron two-argument calls and delegate correctly on three-argument calls; existing test suites exercise only 0/1/3-argument calls, so no test changes are required for them.nanmpcorrdisttest-tolerance fix was validated empirically: 2000-seed simulation of the old assertions (~25% failing seeds), 8000-seed measurement of maximum error (2.5e-11 vs the 2.2e-10 tolerance), and 300 clean full-suite runs under fresh random seeds.NaN-behavior note instats/incr/nanmmpe's README, which already documents the behavior in its intro and usage sections).Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code as part of a scheduled automated review of commits recently merged to
develop, with the test-tolerance fix directed by a maintainer. All findings were cross-validated by multiple independent review passes and verified against the repository before applying fixes.