Last active
August 29, 2015 14:05
-
-
Save Marc-B-Reynolds/0b5f1db5ad7a3e453596 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Experiemental versions of improving the stat properties of a 32-bit (for embedded devices) xorshift | |
without restorting to adding state data. The two versions add one to the dependency chain. | |
Based directly on the work of Sebastiano Vigna - http://xorshift.di.unimi.it/ | |
*/ | |
uint32_t state = 1; | |
// Off the shelf xorshift. | |
// failures from small crush | |
// 1 BirthdaySpacings | |
// 2 Collision | |
// 6 MaxOft | |
// 8 MatrixRank | |
// 10 RandomWalk1 H | |
// failures from small crush (bit reversed) | |
// 1 BirthdaySpacings | |
// 6 MaxOft | |
// 8 MatrixRank | |
// 10 RandomWalk1 H | |
// 10 RandomWalk1 M | |
// 10 RandomWalk1 J | |
// 10 RandomWalk1 R | |
// 10 RandomWalk1 C | |
uint32_t xorshift32(void) | |
{ | |
state ^= (state << 13); | |
state ^= (state >> 17); | |
state ^= (state << 5); | |
return state; | |
} | |
// Based on: Further scramblings of Marsaglia's xorshift generators. | |
// failures from small crush | |
// 1 BirthdaySpacings | |
// failures from small crush (bit reversed) | |
// 1 BirthdaySpacings | |
// 2 Collision | |
// 6 MaxOft | |
uint32_t xorshift32a(void) | |
{ | |
int s0 = state; | |
state ^= (state << 13); | |
state ^= (state >> 17); | |
state ^= (state << 5); | |
return state + s0; | |
} | |
// Based on: An experimental exploration of Marsaglia's xorshift generators, scrambled | |
// failures from small crush | |
// 1 BirthdaySpacings | |
// failures from small crush (bit reversed) | |
// 1 BirthdaySpacings | |
// 6 MaxOft | |
uint32_t xorshift32m(void) | |
{ | |
state ^= (state << 13); | |
state ^= (state >> 17); | |
state ^= (state << 5); | |
return state*1597334677; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment