What does this code mean?

After failures in my attempts to build the Diehard and Dieharder RNG tests on Windows+Cygwin, I turned to the newer L’Ecuyer - Simard TestU01 suite, which I was able to build and run without problems on the RNG posted by the OP. One can read this review paper for a perspective on testing RNGS.

Here is the test program, in C, which is to be linked with the TestU01 library.

#include "unif01.h"
#include "bbattery.h"

double rf(void){
#define IX1 1500419
#define IX2 1400159
const static int ix3 = 1364, ix4 = 1528;
static int ix5 = 1, ix6 = 3;
const static double rr1 = 1.0/IX1, rr2 = 1.0/IX2;
double x;
ix5 = (ix5*ix3) % IX1;
ix6 = (ix6*ix4) % IX2;
x = rr1*ix5+rr2*ix6;
return x < 1 ? x : x-1.0;
}

int main (void)
{
   unif01_Gen *gen;

   gen = unif01_CreateExternGen01 ("FLD12", rf);
   bbattery_SmallCrush (gen);
   unif01_DeleteExternGen01 (gen);

   return 0;
}

The result of the test run was that the OP’s advisor’s RNG did quite well, passing 14 out of 15 tests in the SmallCrush battery (the test that it failed was the BirthdaySpacings test). This RNG also passed all the tests in the PseudoDiehard battery.

I applied the same test batteries to the infamous RANDU RNG. RANDU failed all 15 tests in the SmallCrush battery and 8 of the 10 tests in the PseudoDiehard battery.

I am not qualified to comment about these tests except as a consumer, but I find solace in this quote of L’Ecuyer:

Bad RNGs are those that fail simple tests, whereas good RNGs fail only complicated tests that are hard to find and run.

[Professor Pierre L’Ecuyer is famed as an expert on RNGs.]

3 Likes