Re: RNG Test: Code to generate Diehard file in Euphoria

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Mon, 14 Feb 2000 16:44:09 -0800, Joel Crook <joel at MAIL.K-A.COM> wrote:

>I have the Diehard results for anyone thats interested. Revised code to
>create the hex source file is included below.
>
>revised code:
>
>--randout.txt
>--creates a file for use with the Diehard Tests
>--(c)1999 Joel Hunter Crook
>--free for non-commercial use
>
>include file.e
>
>atom file_number, output1, output2 -- ,final
>sequence file_name , final
>file_name="rndout.txt"
>file_number=open(file_name,"w")
>for i=1 to 150000 do
>       for j=1 to 20 do
>            final={}
>
>
>                output1=rand(#FFFF) -- 4 bytes
>                output2=rand(#FFFF) -- 4 bytes
>                final&=output1&output2
>
>
>-- final now equals 80 bytes or 640 bits
>
>        printf(file_number,"%x",final)
>        end for -- j
>final&="\n \r"
>end for -- i
>close(file_number)

With this slight modification to your code for performance and proper output,
I was able to run the diehard test with the #FFFF key for rand(). The results
appeared to be pretty darn good, with some tests at both ends of the range
and many close to the middle....that is, if I understand what the results mean.
From what I see, rand should be sufficient for almost any normal purpose.
If you are really determined, you could send off for Mr. Masaglia's CDROM
with it't 60 sets of 10,000,000 random integers. By the way, the program
took about 42 seconds to generate 49,201,152 bytes.

--randout.txt
--creates a file for use with the Diehard Tests
--(c)1999 Joel Hunter Crook
--free for non-commercial use
 atom file_number, zero -- ,final
      zero=0
 sequence file_name , final
 final=repeat(zero,20)
 file_name="rndout.txt"
 file_number=open(file_name,"w")
 for i=1 to 600000 do

  final[ 1]=rand(#FFFF) -- 4 bytes
  final[ 2]=rand(#FFFF) -- 4 bytes
  final[ 3]=rand(#FFFF) -- 4 bytes
  final[ 4]=rand(#FFFF) -- 4 bytes
  final[ 5]=rand(#FFFF) -- 4 bytes
  final[ 6]=rand(#FFFF) -- 4 bytes
  final[ 7]=rand(#FFFF) -- 4 bytes
  final[ 8]=rand(#FFFF) -- 4 bytes
  final[ 9]=rand(#FFFF) -- 4 bytes
  final[10]=rand(#FFFF) -- 4 bytes
  final[11]=rand(#FFFF) -- 4 bytes
  final[12]=rand(#FFFF) -- 4 bytes
  final[13]=rand(#FFFF) -- 4 bytes
  final[14]=rand(#FFFF) -- 4 bytes
  final[15]=rand(#FFFF) -- 4 bytes
  final[16]=rand(#FFFF) -- 4 bytes
  final[17]=rand(#FFFF) -- 4 bytes
  final[18]=rand(#FFFF) -- 4 bytes
  final[19]=rand(#FFFF) -- 4 bytes
  final[20]=rand(#FFFF) -- 4 bytes

     -- final now equals 80 bytes or 640 bits
  printf(file_number,
  "%04x%04x%04x%04x%04x%04x%04x%04x%04x%04x",
        {final[ 1],final[ 2],final[ 3],final[ 4],final[ 5],
  final[ 6],final[ 7],final[ 8],final[ 9],final[10]})

  printf(file_number,
  "%04x%04x%04x%04x%04x%04x%04x%04x%04x%04x\n",
        {final[11],final[12],final[13],final[14],final[15],
  final[16],final[17],final[18],final[19],final[20]})



 end for -- i

Everett L.(Rett) Williams
rett at gvtc.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu