I now implemented this as a 32 bit RNG and ran a test on it on a 20 mb file:

#include <stdio.h>

#include <stdlib.h>

#include <windows.h>

#include <time.h>

int main()

{

FILE *fp;

int i;

DWORD dwRandom;

if ((fp = fopen("random.txt", "wb"

) == NULL)

{

printf("File could not be opened\n"

;

return 1;

}

dwRandom = 0x87654321;

for (i = 0; i < 0x500000; i++)

{

dwRandom += (dwRandom * dwRandom) | 5;

fwrite(&dwRandom, 1, sizeof(DWORD), fp);

}

fclose(fp);

return 0;

}

This gave the following results:

Entropy = 7.999997 bits per byte.

Optimum compression would reduce the size

of this 20971520 byte file by 0 percent.

Chi square distribution for 20971520 samples is 99.31, and randomly

would exceed this value 99.99 percent of the times.

Arithmetic mean value of data bytes is 127.4840 (127.5 = random).

Monte Carlo value for Pi is 3.140386118 (error 0.04 percent).

Serial correlation coefficient is 0.000080 (totally uncorrelated = 0.0).

The only test which really stands out is the Chi square test.

Additionally I took a 10 mb file from www.random.org and ran it through the same program which gave the following results:

Entropy = 7.999983 bits per byte.

Optimum compression would reduce the size

of this 10485760 byte file by 0 percent.

Chi square distribution for 10485760 samples is 239.88, and randomly

would exceed this value 50.00 percent of the times.

Arithmetic mean value of data bytes is 127.4760 (127.5 = random).

Monte Carlo value for Pi is 3.141733987 (error 0.00 percent).

Serial correlation coefficient is -0.000196 (totally uncorrelated = 0.0).

Here you see the Chi square test give totally different numbers. Now the question is whats good and whats not. From what I understood reading the discription less then 1% or higher then 99% would be nonrandom data. They give a example of from a radio active source which gives the value 75.00% but I can't really determine which is better between the random file from random.org and this radio active source.

I concluded that the 3 op PRNG is much better then rand() in VC++ which I also ran through the same test. Rand16 from flexlm 7.1x is only half as good as the rand() and unix rand() is better then any of those two but still weaker then the 3 op PRNG.

Maybe someone can comment on this Chi square test.