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

Binomial: Faster sampling for n * p < 10 #735

Merged
merged 3 commits into from Feb 27, 2019

Commits on Feb 26, 2019

  1. Copy the full SHA
    0a44f51 View commit details
    Browse the repository at this point in the history
  2. Binomial: Add benchmark for small n * p

    Our previous implementation was very slow (rust-random#734). The benchmarks makes
    sure we won't have such regressions in the future.
    vks committed Feb 26, 2019
    Copy the full SHA
    6323d29 View commit details
    Browse the repository at this point in the history
  3. Binomial: Use integer exponentation

    This increase performance significantly, see below. However, it requires
    shipping our own integer exponentiation implementation, because `u64`
    exponents are not supported by `std` or `num`.
    
    Before:
    ```
    test distr_binomial       ... bench:  88,365 ns/iter (+/- 2,215) =90 MB/s
    test distr_binomial_small ... bench:  33,775 ns/iter (+/- 5,494) =236 MB/s
    test misc_binomial_1      ... bench:      13 ns/iter (+/- 2)
    test misc_binomial_10     ... bench:      72 ns/iter (+/- 1)
    test misc_binomial_100    ... bench:      71 ns/iter (+/- 11)
    test misc_binomial_1000   ... bench:     624 ns/iter (+/- 19)
    test misc_binomial_1e12   ... bench:     681 ns/iter (+/- 18)
    ```
    
    After:
    ```
    test distr_binomial       ... bench:  44,354 ns/iter (+/- 3,518) = 180 MB/s
    test distr_binomial_small ... bench:  22,736 ns/iter (+/- 514) = 351 MB/s
    test misc_binomial_1      ... bench:      10 ns/iter (+/- 0)
    test misc_binomial_10     ... bench:      23 ns/iter (+/- 0)
    test misc_binomial_100    ... bench:      27 ns/iter (+/- 4)
    test misc_binomial_1000   ... bench:     621 ns/iter (+/- 15)
    test misc_binomial_1e12   ... bench:     686 ns/iter (+/- 20)
    ```
    vks committed Feb 26, 2019
    Copy the full SHA
    5f6f89e View commit details
    Browse the repository at this point in the history