-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add dqrrademacher
#50
Conversation
- I think the problem was bitshifting too far
BTW, the checks via GHA are currently failing, because I need to add some changes from #47. If you don't mind I would cherry pick those changes into this PR. |
LGTM! Do you want to add yourself as contributor in |
Great, Just added myself! Thanks for your help Ralf! |
Thanks for the contribution! It will take a while until this makes its way to CRAN, since I want to finish #47 first. In the meantime, it should soon be available from https://daqana.r-universe.dev/dqrng. |
In statistics, a lot of methods require drawing Rademacher weights, -1 and 1, with probably 1/2 each (e.g. bootstrapping and approximations). To minimize the number of random numbers needed, I draw random 64 bits and use each bit of the integer (which is 0/1 with equal probability) and uses that as a 0/1 variable. It's about 8x as fast as
dqrng::sample(c(-1, 1))
!I believe I fixed the segfault (user error on 0-based indexing in C++ 🤦🏼♂️). I tested for segfaults by calling the following and nothing came-up, so I think we're good.
Benchmarks
Created on 2023-07-01 with reprex v2.0.2