-
-
Notifications
You must be signed in to change notification settings - Fork 433
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
fix accuracy of IteratorRandom::choose() #1059
Conversation
IteratorRandom::choose also guarantees O(1) performance for slices, so there is no need to recommend an alternative
Could you add before/after benchmarks please? |
6d5041d
to
7d8af10
Compare
Ran benches. The commit removing the special case for After backing that commit out, the two benchmarks affected by these changes are seq_iter_unhinted_choose_from_1000 and seq_iter_window_hinted_choose_from_1000. master: this branch: |
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.
Thanks kazcw. Can you squash-merge?
The value stability tests seem to be failing. Could you please fix this?
Why squash? The commits seem to be independent enough. |
f64 reciprocal is inexact, with residuals on the order of 1 / 2^54. For example: the probability gen_bool(1.0 / 3) == true is: 6004799503160661/18014398509481984 Using gen_range is exact for all values of `consumed`. NOTE: this is a value stability-breaking change fixes rust-random#1058
7d8af10
to
a37a599
Compare
Because the individual commits are tiny, and GitHub preserves the individual commits in the PR anyway (e.g. 05a7ab3 is a squash while its PR has 16 commits). For larger PRs I don't think this is optimal but for small ones it seems sensible, if not really significant. |
OTOH these commits have useful commit messages, so I'll go ahead and use a merge commit. |
Fix accuracy bug in #1058. This is a value-stability-breaking change.