Project 118: True Random Number Generator DIEHARD Results

 

I have recently completed analysis of my True Random Number generator by subjecting it to the rigorous DieHard testing suite. This software application was created by George Marsaglia and is available here: DieHard.

I tried various other testing suites, including NIST (various versions)  and Robert G. Brown's  DieHarder, a more up to date version of DieHard. However, a lot of these tools either didn't compile under windows (including Cygwin) or didn't produce reliable results, so I used the older DieHard suite.


DieHard tests were done on Five sets of data, generated by five different methods:

 

Test 1 was a PseudoRandom algorithm, a simple implementation of rand() in C++

Test 2 was a PseudoRandom algorithm with a normal distribution, using std::tr1::normal_distribution in C++.

Test 3 was generated from random background noise, using an Arduino with the RNG circuit connected, but not switched on.

Test 4 was generated from white noise using the RNG connected to the Arduino, and should be true random.

Test 5 was a combination of Test 1 and Test 4. It was the same pseudorandom algorithm, seeded at regular intervals using white noise.


The results are presented in the following table:

 


It's clear the the True Random Generator didn't work as expected, but, considering C++'s "built in" rand() function only passed one of the tests, this may not be unusual. The Die hard tests are so named for a reason.

I am not certain why the RNG didn't work as expected, I verified that the output was in fact white noise, I made sure the data was transmitted, formatted, and tested correctly, and I conducted a Fast Fourier Transform analysis of the RNG during operation. It had a flat distribution, which is what you would expect. Once the RNG was switched off, clear spikes could be seen, which indicates non-random operation.

 

 
Random Noise: (RNG in operation)

 

Flat FFT analysis, no spikes, during RNG operation:

 
RNG switched off, notice spikes  on FFT analysis which indicate non-random input:


 I also verified that the numbers being generated were non random, and they seemed to be. I suspect the issue lies between the white noise circuit and the testing circuit, ie, the white nosie is not being processed and converted to data correctly. Possibly because the Arduino is not powerful enough to pick up the kind of signal I am generating?

As well as learning a lot about Random Number Generation and testing, I also wrote some useful software tools for this project. I wrote a program to generate very large text and hex files containing the random numbers to be tested, as well as print a 1024 x 1024 image of random pixel values. I also learned to use the Arduino as an oscilloscope using various resources, learned how to use Cygwin ( Which should prove very useful in future, many tools are available on linux only) and of course, learning to use the RNG testing tools was quite a challenge in itself.


I then tested the data using ENT, and I did notice that my RNG seemed to perform better than the pseudorandom RNG.


The results of the ENT tests are:


This is certainly encouraging, it seems I did achieve some success after all.


The following are the randomly generated images that I made from the 5 data sets. The pseudo random images look truly random, while the background random image has noticeable patterns. The true random image doesn't look too bad, but it also has some noticeable patterns.

 

 Psuedo Random image:

Pseudo random image with a normal distribution:

Pseudo/True random Combination:

 

Background Radiation:

 

True Random:


 
These are the Test results from Diehard:
 

TRUERRST.txt PTRCRST.txt BKGRRST.txt PRRST.txt PRNRST.txt


 

You must be a member of this blog to see the comments. Log in now!