-
-
Notifications
You must be signed in to change notification settings - Fork 434
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
SmallRng uses wrong seed_from_u64 implementation #1203
Conversation
There is discussion on this in #1038. I'm not really convinced it's worth introducing a breaking change for this. In any case, we make zero guarantees about compatibility of
This is a value-breaking change. We haven't merged breaking changes yet but probably will soon. |
I agree it's a bug, because |
@vks do you think it is reasonable to increase the tolerance of your normal distribution sparkline test here? |
@dhardy Sure, it seems the test failed only 0.4 % of the tolerance. I should probably calculate the probability of failing with the current tolerance to determine a better threshold. |
This still needs an update to the changelog and a fix for the tolerance of the test. |
I modified the test by feeding all the numbers in the range
This means that 22/100 random seeds failed the unit test with error more than 3 standard deviations from expected. The other solution would ditch the truly obvious seed of 1 and pick a fair random number like 4 to move on. |
Thanks for investigating this! That's a much higher failure rate than what I would fundamentally expect for the 3 standard deviations threshold. I'll need to take a closer look at the error distribution. |
This only needs updating the changelog for 0.9, documenting the value-breaking change to |
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.
I check all merged PRs when writing changelogs anyway (we always miss some), so I can fix that then).
Currently
SmallRng
implementsSeedableRng
but it does not specify aseed_from_u64
method soSmallRng
uses the default (pcg32) trait implementation. Because of this the Xorshiro'sseed_from_u64
method using Splitmix64 is effectively dead code. Splitmix64 is recommended for seeding Xorshiro by opinionated people so this is definitely a bug.The documentation for
seed_from_u64
says changing the algorithm is a "value-breaking change" but on the other hand the current implementation is a unintended bug so might not be protected from breaking changes.Should this wait for the next breaking version or be merged immediately?