Repository navigation
test(crypto): make the numeric() distribution test non-flaky - #81
Merged
Merged
Conversation
The distribution test allowed each digit 3% deviation over 100k draws. That is only ~3 standard deviations, so a healthy generator failed it on roughly 1-2% of runs — it turned master CI red (digit 2 at 3.04%). Simply widening the bound would stop it catching the modulo bias it exists for (~2% per digit). It is now a Pearson chi-squared test over 1M digits (9 dof, threshold 42.6 ⇒ false-positive rate 1e-6). A byte % 10 generator scores ~400 and still fails.
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.
What / why
packages/crypto/tests/random/numeric.test.jsturned master CI red after #79 merged (digit 2: count=9696, deviation=0.0304). The test allowed each digit 3% deviation over 100k draws, which is only ~3σ, so a healthy generator failed it on about 1-2% of runs. Nothing in the merged change touched@exortek/crypto.Widening the bound alone would stop the test catching the modulo bias it exists for (~2% per digit), so it is now a Pearson chi-squared test over 1M digits (9 degrees of freedom, threshold 42.6 → false-positive rate 1e-6). A
byte % 10generator scores ~400 and still fails. 20/20 local runs pass.Which package(s)?
@exortek/crypto(tests only)Type of change
Checklist