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

mixGamma should fix results with low popcount #2

Closed
Lysxia opened this issue May 13, 2018 · 1 comment
Closed

mixGamma should fix results with low popcount #2

Lysxia opened this issue May 13, 2018 · 1 comment

Comments

@Lysxia
Copy link

Lysxia commented May 13, 2018

The mixGamma function should "fix" its result if the popcount is too low, but in its current version it is doing the opposite.

pringo/stubs.c

Lines 77 to 78 in fa170bc

if (popcount64(z ^ (z >> 1)) >= 24) z ^= 0xaaaaaaaaaaaaaaaaULL;
return z;

This is a bug inherited from a typo in the code of the original SplitMix paper. The text gives the correct interpretation:

Therefore we require that the number of such pairs, as computed by Long.bitCount(z ^ (z >>> 1)), exceed 24; if it does not, then the candidate z is replaced by the XOR of z and 0xaaaaaaaaaaaaaaaaL

I found that in this blogpost: http://www.pcg-random.org/posts/bugs-in-splitmix.html

@xavierleroy
Copy link
Owner

Thanks a lot for reporting this error.

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

No branches or pull requests

2 participants