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

Unbiased uniformR for Integer #66

Merged
merged 2 commits into from
Apr 8, 2020

Conversation

curiousleo
Copy link
Collaborator

@curiousleo curiousleo commented Apr 2, 2020

Benchmarks: #66 (comment)

  • Get doctests to build
  • Get CI to pass
  • Add benchmarks

@curiousleo curiousleo changed the title Uniform integer [WIP] Uniform integer Apr 2, 2020
@curiousleo curiousleo force-pushed the uniform-integer branch 2 times, most recently from eea2cd2 to 2924326 Compare April 3, 2020 07:22
@idontgetoutmuch
Copy link
Owner

This looks good to me - nice work!

@lehins lehins changed the base branch from instances-and-warnings to interface-to-performance April 4, 2020 20:11
@peteroupc
Copy link

peteroupc commented Apr 6, 2020

For your information, I give references to alternative ways to generate random integers in a range:

Only the unbiased (exact) algorithms are probably of interest here.

@curiousleo
Copy link
Collaborator Author

curiousleo commented Apr 6, 2020

Only keeping the relevant output lines, I get:

How many random numbers can we generate in a second on one thread?                   
  First, timing System.Random.next:                             BEFORE                 AFTER
  Second, timing System.Random.random at different types:                            
      1,664,242 randoms generated [System.Random Integers]    ~ 1,041 cycles/int     ~ 15.15 cycles/int
  Next timing range-restricted System.Random.randomR:                                
      3,187,431 randoms generated [System.Random Integers]    ~ 544 cycles/int       ~ 494 cycles/int
         31,100 randoms generated [System.Random BIG Integers] ~ 55,729 cycles/int    ~ 53,271 cycles/int
Now 8 threads, reporting mean randoms-per-second-per-thread:                         
  First, timing System.Random.next:                                                  
  Second, timing System.Random.random at different types:                            
        597,614 randoms generated [System.Random Integers]    ~ 2,900 cycles/int     ~ 36.71 cycles/int
  Next timing range-restricted System.Random.randomR:                                
      1,274,940 randoms generated [System.Random Integers]    ~ 1,359 cycles/int     ~ 1,130 cycles/int
         15,678 randoms generated [System.Random BIG Integers] ~ 110,549 cycles/int   ~ 108,321 cycles/int

Edit: updated.

@curiousleo curiousleo changed the title [WIP] Uniform integer Unbiased uniformR for Integers Apr 6, 2020
@curiousleo curiousleo changed the title Unbiased uniformR for Integers Unbiased uniformR for Integer Apr 6, 2020
@curiousleo curiousleo marked this pull request as ready for review April 6, 2020 08:09
@curiousleo curiousleo force-pushed the uniform-integer branch 3 times, most recently from 445679c to ef71573 Compare April 6, 2020 14:26
@curiousleo
Copy link
Collaborator Author

Ready for review.

Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure I can say I understand why all this works, but it looks like you did the leg work and overall looks to match the paper

@curiousleo curiousleo requested a review from lehins April 7, 2020 07:32
@idontgetoutmuch idontgetoutmuch merged commit 3c8f709 into interface-to-performance Apr 8, 2020
@idontgetoutmuch idontgetoutmuch deleted the uniform-integer branch April 8, 2020 06:35
curiousleo pushed a commit that referenced this pull request May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants