KISS (random number generator)

from Wikipedia, the free encyclopedia

KISS is a random number generator developed by George Marsaglia .

Its name comes from the KISS principle , the generator is a combination of three simple random number generators:

Each of these generators on its own has practically no tests for randomness. However, the combination in the form of the KISS generator consists of all statistical tests from the BigCrush test of the TestU01 library.

properties

  • Period length:
    • greater than 2 124 ≈ 2.12 10 37 (32-bit version)
    • greater than 2 247 ≈ 2.26 10 74 (64-bit version)
  • Small state vector: 4 values ​​of 32 or 64 bits each
  • uses only simple arithmetic operations: shift, addition, multiplication
  • easy implementation

Implementation in C

32 bit 64 bit
#include <stdint.h>

// interner Zustand
static uint32_t x = 123456789; // seed beliebig,
static uint32_t y = 362436000; // aber y != 0 und
static uint32_t z = 521288629; // z,c nicht beide 0
static uint32_t c = 7654321;

uint32_t KISS() {
   uint64_t t;

   // Linearer Kongruenzgenerator
   x = 69069 * x + 12345;

   // Xorshift
   y ^= y << 13;
   y ^= y >> 17;
   y ^= y << 5;

   // Multiply-with-carry
   t = (uint64_t)698769069 * z + c;
   c = t >> 32;
   z = (uint32_t) t;

   return x + y + z;
}
#include <stdint.h>

// interner Zustand
static uint64_t x = 1066149217761810ULL;
static uint64_t y = 362436362436362436ULL;
static uint64_t z = 1234567890987654321ULL;
static uint64_t c = 123456123456123456ULL;

uint64_t KISS64() {
   uint64_t t;

   // Linearer Kongruenzgenerator
   x = 6906969069ULL * x + 1234567;

   // Xorshift
   y ^= y << 13;
   y ^= y >> 17;
   y ^= y << 43;

   // Multiply-with-carry
   t = (z << 58) + c;
   c = z >> 6;
   z += t;
   c += z < t;

   return x + y + z;
}

See also

Individual evidence

  1. Journal Of Modern Applied Statistical Methods, May, 2003, Vol. 2 (PDF; 9.5 MB)
  2. ^ Pierre L'Ecuyer, Richard Simard: TestU01: AC library for empirical testing of random number generators . In: ACM Transactions on Mathematical Software , Volume 33, Issue 4, August 2007
  3. https://www.thecodingforums.com/threads/64-bit-kiss-rngs.673657/