-
Notifications
You must be signed in to change notification settings - Fork 0
Add CPRNG #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Update CI pipeline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a cryptographically secure pseudo-random number generator (CPRNG) to the rtcompare package, providing an alternative to the existing deterministic DPRNG for scenarios requiring cryptographic-strength randomness or unpredictable inputs.
Key changes:
- New CPRNG implementation backed by crypto/rand with buffered reads for performance
- Integration of CPRNG into bootstrap sampling (activated when seed=0)
- Addition of F2T helper function for converting multiplicative speedup factors to threshold values
- Documentation updates across README and inline comments
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| cprng.go | Implements the new CPRNG type with buffered crypto/rand reads and methods for generating various random number types (Uint64, Float64, Uint32N, etc.) |
| cprng_test.go | Comprehensive test suite including uniformity tests using chi-squared statistics, bounds checking, and performance comparison tests |
| rtcompare.go | Updates bootstrapSample to use CPRNG when prngSeed=0; adds F2T helper function; improves documentation for RTcomparisonResult and bootstrap functions |
| rtcompare_test.go | Adds test for high relative gains (>100% speedup) using deterministic identical samples |
| dprng.go | Fixes spelling errors in comments ("randum" → "random") and clarifies thread-safety documentation |
| README.md | Documents the new CPRNG feature and explains when to use DPRNG vs CPRNG |
| .gitignore | Adds .DS_Store to ignore macOS system files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Critical bug: When prngSeed is non-zero, every call to bootstrapSample in the loop will create a new DPRNG with the same seed, causing all bootstrap resamples to be identical. This defeats the purpose of bootstrap resampling. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Tom Tonic <tom@tomtonic.de>
Co-authored-by: TomTonic <20836927+TomTonic@users.noreply.github.com>
Co-authored-by: TomTonic <20836927+TomTonic@users.noreply.github.com>
Add test coverage for F2T function
No description provided.