* The DIEHARD tests of random number generators by George Marsaglia
* can be found at 
*
* https://web.archive.org/web/20160125103112/http://stat.fsu.edu/pub/diehard/
*
* DIEHARD requires 3 million 32-bit integers generated by the random
* number generator.

* Created for Stata 18 on 2023-03-30

clear all
set obs 3000000

* reset the seed to the default
set seed 123456789

* We use -long- storage type to get 32-bit integers
*
* In
*
*    McCullough, Brian D. 1999. "Assessing the Reliability of Statistical
*    Software: Part II", The American Statistician 53(2): 149-159
*
* it indicates (on page 156) that the integers are to be calculated as
*
*    INT(-2147483649 + 4294967297*RAN)
*
gen long x = int(-2147483649 + 4294967297*runiform())

* The DIEHARD programs require a certain format for the data.  It wants
* the numbers 10 on a line in hexadecimal representation in an ascii file.
* There is then a DIEHARD utility program that takes this kind of file and
* produces another binary file that DIEHARD actually uses.  McCullough
* (see reference above) suggests just writing the numbers to an ascii file
* and then writing a simple program to translate that into the format that
* the DIEHARD utility program desires.

outfile x using randnumb_mt64.raw

* The C program raw2bin.c will take a file like randnumb.raw produced
* above and create the binary file that the diehard program desires.

exit