Skip to content
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

Merged
merged 3 commits into from Oct 17, 2020

Commits on Oct 11, 2020

  1. remove unneccessary admonition from choose docs

    IteratorRandom::choose also guarantees O(1) performance for slices, so
    there is no need to recommend an alternative
    kazcw committed Oct 11, 2020
    Copy the full SHA
    7f6eca4 View commit details
    Browse the repository at this point in the history

Commits on Oct 13, 2020

  1. Copy the full SHA
    dab98b3 View commit details
    Browse the repository at this point in the history

Commits on Oct 16, 2020

  1. accurate IteratorRandom::choose()

    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
    kazcw committed Oct 16, 2020
    Copy the full SHA
    a37a599 View commit details
    Browse the repository at this point in the history