-
Notifications
You must be signed in to change notification settings - Fork 432
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 xoroshiro128+ generator. #102
Conversation
This is based on the reference code given in [1], sourced from [2]. The authors position xoroshiro128+ as the successor to xorshift128+, with better statistical properties *and* higher performance [2]. This implementation does *not* contain the `jump` function. [1]: http://xorshift.di.unimi.it/xoroshiro128plus.c [2]: http://xorshift.di.unimi.it/
I feel like all sorts of the odd generators (i.e. everything other than what we already have to support) belong in external crates. |
@nagisa On the one hand, not having to compile every possible RNG just because you want to use one of them is good. On the other, it's called " Mostly, I made this PR because someone else had exactly the same idea as I did, at more or less exactly the same moment, so I took that as a sign. If this gets turned down, I'll just spin it into an external crate; no biggie. |
The next major version of rand could incorporate this as a replacement for Xorshift and as the implementation for weak_rng. The weak rng could also be "anonymized" in the API and maybe not even expose it as Xorshift or Xoroshiro or anything in particular. |
#[inline] | ||
fn next_u32(&mut self) -> u32 { | ||
self.next_u64() as u32 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to reuse the second half of the 64-bit integer if a second 32-bit integer is requested? Or is this slower due to the additional branch?
Thanks for the PR @DanielKeep! The libs team discussed this PR during triage yesterday, and the conclusion was that for now we don't want to include any other RNG implementations in the Unfortunately this crate is lacking a vision of how to proceed forward which makes it difficult to say whether we want this sort of RNG eventually. We hope to start devoting some time to this crate soon, but help is always appreciated! In the meantime I'm gonna close this, but please feel free to publish this on crates.io! |
Since the author considers it to be a replacement for xorshift, I think it's logical to consider it as its replacement in rand. |
Sure, but it's not even clear whether xorshift should itself be in rand, unfortunately. |
I see. Is it too early to stagnate this crate maybe? Is it important we shoot for an 1.0 version soon? Maybe we should instead develop it more, the distributions are pretty far away from being 1.0-ready IMO. |
To be clear, we certainly don't want this crate to stagnate! We'd love to move this crate to 1.0, but it would require someone to take up the banner of doing that, and we don't currently have anyone to do that. Until that happens additions like new RNG implementations is both controversial and also easy to do out of tree, so the decision is that in the meantime we won't change it until there's a vision moving forward. |
... If someone on this thread would like to take up the banner for |
Yeah it makes sense. I can be maintainer, so if we have someone be that, then we can entertain incremental and evolutionary changes to the library again? |
@bluss certainly! We're just hesitant to make changes without an overall vision, but if we've got someone with that vision then there's something concrete to talk about and discuss. Both @huonw and @jonathandturner have taken a look at upping our |
@DanielKeep I published this on crates.io. Do you want me to add you to the authors or transfer ownership of the repository/crate to you? |
@vks Sorry for late reply: I don't think the code is complicated enough to worry about authorship or ownership. I just translated the reference code. To everyone else: sorry for the thread bump. |
This is based on the reference code, sourced from the author's website.
The authors position xoroshiro128+ as the successor to xorshift128+,
with better statistical properties and higher performance (see their website).
This implementation does not contain the
jump
function.Summary of benchmark numbers for a x86_64-pc-windows-msvc nightly 2016-02-12:
The same for i686-pc-windows-gnu nightly 2016-04-20:
Yes, it is slower than xorshift on 32-bit, though it's still faster than everything else.