Tuesday, January 10, 2006

Diehard battery of tests

There is a battery of tests that assess the randomness of a sequence of (pseudo-)random numbers, called the Diehard battery of tests. We have been assigned a task to run this battery of tests on random numbers generated by MS Excel and Matlab. It's a strange set of tests in the sense that it requires an input file of 10 to 11 MB, containing nothing but random numbers and the file needs to be in binary format.
I used C++ to generate such a number (2867200 to be precise) of random numbers and dumped it to a binary file of 11.2 MB. I'll upload the code to do that soon.
The squeeze test always failed. I tried to increase and decrease the size of the file but to no avail. Ultimately, I stumbled onto the fact that the random numbers were not in the range from 0 to 2^32 - 1. What I was generating were 0 to 2^16 - 1. This is just so if someone stumbles into this problem and does a search, hopefully they would bump into this.
Now I am working to generate such a file from within Excel.

3 comments:

Whiz Kid said...

Were you not required to implement those algorithms by yourself? That would have been fun.

Keep on sharing everything and some people will do an unofficial thesis-less PhD with you ;)

Whiz Kid said...

Are you doing this: =4294967295*RAND() or something special?

Muhammad Saqib Ilyas said...

Yes, we are implementing a few tests ourselves. I just did =2^32*rand(). No need to do anything special. Unless you call using C# to use interop to generate those millions of random numbers special. I'll upload the code and stuff soon when I am done with it.