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

Use single call to dsfmt_gv_genrand_uint32() for small ranges (Take 2) #5741

Merged
merged 2 commits into from
Apr 28, 2014

Conversation

mschauer
Copy link
Contributor

@mschauer mschauer commented Feb 9, 2014

This fixes #5549 and is an extended version of #5578 to accommodate for future changes to Range1, see #5585

This is tricky to test (e.g. it is not possible to check if rand(1:2^50) covers the full range or is exactly uniform...) so please have a close look for one-off-errors and ideas for good tests are welcome.

@mschauer
Copy link
Contributor Author

@lindahua I am interested, what do you think? Speed diagram below.

rand32
Speed of rand(1:t, 10^6) for different values of t (dots) and of rand(uint32(1:t), 10^6) circles. The PR in red. Everything as expected, notably rand(0x00000001:0x80000000, 10^6) is faster than before (it fits twice into 2^32, but not into 2^32-1) and rand(0x0000000000000001:0x0000000080000001, 10^6) is slower than before and rand(typemin(Uint32):typemax(Uint32), 10^6) does not fail anymore.

@mschauer
Copy link
Contributor Author

I just rebased this and thanks to recent improvements in the testing code for linear algebra (progress #5605) this passes now the tests.

@ViralBShah
Copy link
Member

Could you rebase this one again?

@JeffBezanson
Copy link
Sponsor Member

Yes this would be nice to have.

@mschauer
Copy link
Contributor Author

Ok, it is rebased on top of master.

ViralBShah added a commit that referenced this pull request Apr 28, 2014
Use single call to dsfmt_gv_genrand_uint32() for small ranges (Take 2)
@ViralBShah ViralBShah merged commit 2341d02 into JuliaLang:master Apr 28, 2014
@ViralBShah ViralBShah added the domain:randomness Random number generation and the Random stdlib label Nov 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:randomness Random number generation and the Random stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

srand(123); rand(1:10, 100) produces different random numbers on different machines.
3 participants