Skip to content

improve performance of rand(n:m) #29004

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

Closed
jlapeyre opened this issue Sep 2, 2018 · 2 comments
Closed

improve performance of rand(n:m) #29004

jlapeyre opened this issue Sep 2, 2018 · 2 comments
Labels
performance Must go faster randomness Random number generation and the Random stdlib

Comments

@jlapeyre
Copy link
Contributor

jlapeyre commented Sep 2, 2018

A recently published algorithm is unbiased and more performant than rand(n:m).

See https://discourse.julialang.org/t/rand-1-10-vs-int-round-10-rand/14339/10.

@rfourquet rfourquet added performance Must go faster randomness Random number generation and the Random stdlib labels Sep 2, 2018
@affans
Copy link
Contributor

affans commented Sep 2, 2018

Reference issue on the speed of rand() #20582
Maybe the PR there can be updated to use this algorithm.

StefanKarpinski added a commit that referenced this issue May 1, 2020
* implement "nearly division less" algorithm for rand(a:b)

Cf. https://arxiv.org/abs/1805.10941.
Closes #20582, #29004.

* fix overflow error in tests

* make NDL the default algo

* update NEWS.md

* try make tests pass on 32-bits machines

* add a comment for mod(-s, s)

* remove vestigial transient `fast` function, and update comments
@rfourquet
Copy link
Member

Closed by #29240.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster randomness Random number generation and the Random stdlib
Projects
None yet
Development

No branches or pull requests

3 participants