lundi 16 avril 2018

How can I test if CRC32C a "good" random generator?

I recently discovered that the _mmcrc32 intel intrinsic instruction could be used to generate (pseudo-)random 32 bit numbers.

#include <nmmintrin.h> /* needs CRC32C instruction from SSE4.2 instruction set extension */

uint32_t rnd = 1; /* initialize with seed != 0 */

/* period length is 4,294,967,294 = 2^32-2 */
while (1) {
    rnd = _mm_crc32_u8(rnd, rnd >> 3);
    printf("%08X\n", rnd);
}

This method is as fast as a LCG, and faster than xorshift32. Wikipedia says that because xorshift generators "fail a few statistical tests, they have been accused of being unreliable".

Now I am wondering if the CRC32C method passes the various tests that are done on random number generators. I only verified that each bit, even the LSB, is "random" by trying to compress using PAQ8 compressors (which failed). Can someone help me do better tests?




Aucun commentaire:

Enregistrer un commentaire