Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Brian Broker <bkb at CNW.COM> Feb 17, 2000
- 690 views
On Thu, 17 Feb 2000 19:43:52 -0500, Everett Williams wrote: >I also meant to say that none of the three tests that were in a previous >post met the input criteria for diehard except maybe the concatenation. The first two input files I generated (the shifted and unshifted) were included because you thought the "results might be instructive if it will accept the set at all." The shifted results do, in fact, meet the input criteria, as Joel pointed out from the Diehard docs: Your random number generator should produce 32-bit integers. (If 31 bits, left justify by shift-left-one, as some of the tests in DIEHARD favor leading bits.) I just did a shift-left-two on a 30-bit result... >There is no apparent limitation of rand() to #3FFFFFFF range. That is the >integer range and will be the limit if an integer is used as input and >output. If #FFFF is used as input and atom is used as output, a full range >appears to be achieved. I'm not sure if I follow you here. The Euphoria documentaion states that rand(x1) will "Return a random integer from 1 to x1, where x1 may be from 1 to the largest positive value of type integer (1073741823)." If I have an atom 'random_atom' and I do: random_atom = rand( #FFFF ) I will get a result between #00000001 and #0000FFFF which is clearly a 16- bit random number that excludes the possibility of getting a result of #0000. To get a true 32-bit random number using 16-bit concatenation you would need a function like this: function rand32() return ( rand( #10000 ) - 1 ) * #10000 + ( rand( #10000 ) - 1 ) end function -- Brian (only justifing my test results)