Repository navigation
Fix weighted batch accumulation and stabilize the normality test - #147
Merged
Merged
Conversation
Convert mixed-type observations and weights before multiplication, matching scalar insertion and avoiding overflow in input types. Preserve the existing mapping when operand and accumulator types match. Add regression tests for integer and floating-point overflow and batch/scalar consistency. AI-Assisted-By: Codex (GPT-6 Astra Medium)
Capture the element count before summation consumes the input range. Add regression tests for initial, exhausted, and repeated insertion with naive and pairwise summation. AI-Assisted-By: Codex (GPT-6 Astra Medium)
Use std.math.asinh to avoid cancellation for negative and near-zero skewness. Add regression tests for transformation symmetry and reflected samples across float, double, and real. AI-Assisted-By: Codex (GPT-6 Astra Medium)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix three correctness issues in weighted accumulation and the D’Agostino–Pearson normality test, with a separate commit for each.
Weighted batch multiplication
Convert observations and weights to their accumulator operand types before multiplying, matching scalar insertion. Previously, products could overflow in the input type even when the accumulator could represent them—for example, multiplying two
50_000integers before accumulating intodouble.Keep the existing multiplication mapping when input and accumulator types already match. Mixed-type calculations can change rounding because conversion now happens before multiplication.
Shared-cursor input ranges
Capture the observation count before summation consumes a shaped input range. Previously, ranges whose copies share a cursor could report zero remaining observations after summation, producing an incorrect total weight.
This changes operation ordering without adding a traversal or allocation.
Normality-test stability
Replace
log(x + sqrt(x*x + 1))withstd.math.asinh(x)in the skewness transformation. This avoids cancellation for negative and near-zero inputs and restores consistent results for reflected samples.Validation