1. RNG Test: Code to generate Diehard file in Euphoria
- Posted by Joel Crook <joel at MAIL.K-A.COM> Feb 14, 2000
- 583 views
--=====================_21804193==_.ALT The following code generates a 15MB file of random numbers. Output is in hex. --randout.txt --creates a file for use with the Diehard Tests --(c)1999 Joel Hunter Crook --free for non-commercial use atom file_number, output1, output2 -- ,final sequence file_name , final file_name="rndout.txt" file_number=open(file_name,"w") for i=1 to 4000000 do final={} for j= 1 to 10 do output1=rand(#FFFF) -- 4 bytes output2=rand(#FFFF) -- 4 bytes final&=output1&output2 end for -- j -- final now equals 80 bytes or 640 bits printf(file_number,"%x",final) end for -- i At 03:15 PM 02/14/2000 -0500, you wrote: >I believe that one of the standard tests for randomness is to treat the input >file as a bit stream and measure the distance between ones and then throw >that into various statistical distributions. The unshifted, unfilled version of >the numbers is likely to produce a major peak in this set of calculations, but >it still might be instructive to see just what it does generate. > >Everett L.(Rett) Williams >rett at gvtc.com Joel H. Crook Manager, Information Services Certified Novell Administrator Microsoft Certified Professional, OS Specialist Kellogg & Andelson Accountancy Corp. 14724 Ventura Blvd. 2nd Floor Sherman Oaks, CA 91403 (818) 971-5100 --=====================_21804193==_.ALT <html><div>The following code generates a 15MB file of random numbers. Output is in hex.</div> <br> <div>--randout.txt</div> <div>--creates a file for use with the Diehard Tests</div> <div>--(c)1999 Joel Hunter Crook</div> <div>--free for non-commercial use</div> <div> </div> <div>atom file_number, output1, output2 -- ,final</div> <div>sequence file_name , final</div> <div>file_name="rndout.txt"</div> <br> <div>for i=1 to 4000000 do</div> j= 1 to 10 do</div> <br> -- 4 bytes</div> -- 4 bytes</div> <br> for -- j</div> <div>-- final now equals 80 bytes or 640 bits</div> <div>end for -- i</div> <br> <br> <br> <br> <div>At 03:15 PM 02/14/2000 -0500, you wrote:</div> <div>>I believe that one of the standard tests for randomness is to treat the input</div> <div>>file as a bit stream and measure the distance between ones and then throw</div> <div>>that into various statistical distributions. The unshifted, unfilled version of</div> <div>>the numbers is likely to produce a major peak in this set of calculations, but</div> <div>>it still might be instructive to see just what it does generate.</div> <div>></div> <div>>Everett L.(Rett) Williams</div> <div>>rett at gvtc.com</div> <br> Joel H. Crook<br> <br> Manager, Information Services<br> <font size=1>Certified Novell Administrator<br> Microsoft Certified Professional, OS Specialist<br> <br> </font><b>Kellogg & Andelson Accountancy Corp.<br> </b><font size=1>14724 Ventura Blvd. 2nd Floor<br> Sherman Oaks, CA 91403<br> (818) 971-5100<br> </font></html> --=====================_21804193==_.ALT--
2. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Joel Crook <joel at MAIL.K-A.COM> Feb 14, 2000
- 576 views
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)
3. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Everett Williams <rett at GVTC.COM> Feb 16, 2000
- 657 views
- Last edited Feb 17, 2000
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
4. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Irv Mullins <irv at ELLIJAY.COM> Feb 17, 2000
- 557 views
On Wed, 16 Feb 2000, Everett Williams wrote: <snip code> > -- 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]}) Just so that newcomers to Euphoria aren't put off by the seeming complexity of the above, they should be aware that the previous lines can be replaced with: printf(file_number, fmt, final) providing that fmt has been previously defined or built programmatically, i.e. sequence fmt fmt = "" for i = 1 to 20 do fmt &= "%04x" end for fmt &= '\n' Euphoria's printf() statement will use as many data items as needed to match the number of items in the format string, and ignore the rest (if any) Only when there are fewer data items than format items will there be an error. This is a nice feature that can sometimes save a lot of typing, with little or no impact on execution speed. Regards, Irv
5. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Everett Williams <rett at GVTC.COM> Feb 17, 2000
- 531 views
Irv Mullins wrote: >On Wed, 16 Feb 2000, Everett Williams wrote: > ><snip code> > >> -- 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]}) > >Just so that newcomers to Euphoria aren't put off by the seeming complexity of >the above, they should be aware that the previous lines can be replaced with: > >printf(file_number, fmt, final) > >providing that fmt has been previously defined or built programmatically, i.e. >sequence fmt > fmt = "" > for i = 1 to 20 do > fmt &= "%04x" > end for > fmt &= '\n' > >Euphoria's printf() statement will use as many data items as needed to match >the number of items in the format string, and ignore the rest (if any) Only >when there are fewer data items than format items will there be an error. >This is a nice feature that can sometimes save a lot of typing, with little or >no impact on execution speed. > >Regards, >Irv Irv, Certainly, it would be theoretically faster to move the creation of fmt outside the loop, but any compiler with any kind of optimizing capability will take any literal like this and treat it like a constant and move it outside the loop. The use of a variable will cause the compiler to have to check the value of fmt every time it sees it. The fastest way would be to create the value and assign it to fmt as a constant. To a C programmer, what you did is perfectly natural and normal. Less complex is a description that would only apply to this if what you describe made it clearer. I don't believe that is the case. Since I have reviewed a lot of C code, but am not a C programmer, the &=, +=, etc. constructs are not natural to me. Syntactically, they are the equivalent of a macro. They cannot easily be described by standard grammars. It is a little like speaking a foreign language. I can recognize the construct when I see it, but when writing, I almost always think x = x+1 and then translate to x += 1 This is probably a handicap of the aged and infirm programmer, but complexity is oft in the eye of the beholder. It might be noted, as in the case of COBOL, verbose does not equal complex, or even, in most cases, less efficient. Also, with modern editors, I didn't type any of those variable names but once...the rest was cut and paste. The advantage to being verbose, where it does not effect performance is that it offers the opportunity to easily alter what is written. Exception code many times just becomes a different coding of an explicit sequence. Where the code becomes large and untenable due to explicit coding, I will agree with your correction. Otherwise, being straightforward has it's advantages. Everett L.(Rett) Williams rett at gvtc.com Everett L.(Rett) Williams rett at gvtc.com
6. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Joel Crook <joel at MAIL.K-A.COM> Feb 17, 2000
- 558 views
--=====================_13980362==_.ALT At 08:10 PM 02/16/2000 -0500, you wrote: >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. And some day I'll get this language figured out. Euphoria is NOT easier to code as advertised. I'm used to pascal conventions where there are exactly two types of read and write statements not C styled incoherance. Euphoria seems to be a cross between "wanna-don't-wanna be" C and TCL without TK and almost C and TCL/TK with the addition of David Cuny's Win32lib. I believe the TCL/TK expr command does support 32 bit bitwise operators. Sorry... Just frustrated.... ...and Everett L.(Rett) Williams was earlier kind enough to reply: >rett at gvtc.com> >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. Yes the RNG appears to be good for everyday purposes BUT p=.500000 for all tests is the optimum. Consistant scores of p>=.9000 or p<=.10000 are not good. If the end objective of using the rand() function REQUIRES uniformly generated random numbers the results I saw did not indicate Euphoria passed all of the tests. Maybe RDS might like to weigh in and state the source and/or type of RNG that is coded into Euphoria. Joel H. Crook Manager, Information Services Certified Novell Administrator Microsoft Certified Professional, OS Specialist Kellogg & Andelson Accountancy Corp. 14724 Ventura Blvd. 2nd Floor Sherman Oaks, CA 91403 (818) 971-5100 --=====================_13980362==_.ALT <html> <dl> <dd>At 08:10 PM 02/16/2000 -0500, you wrote: <dd>>On Mon, 14 Feb 2000 16:44:09 -0800, Joel Crook <joel at MAIL.K-A.COM> wrote: <dd>> <dd>>>I have the Diehard results for anyone thats interested. Revised code to <dd>>>create the hex source file is included below.<br> <br> </dl>And some day I'll get this language figured out. <br> <br> Euphoria is NOT easier to code as advertised. I'm used to pascal conventions where there are exactly two types of read and write statements not C styled incoherance. <br> <br> Euphoria seems to be a cross between "wanna-don't-wanna be" C and TCL without TK and almost C and TCL/TK with the addition of David Cuny's Win32lib. I believe the TCL/TK expr command does support 32 bit bitwise operators. Sorry... Just frustrated....<br> <br> ...and Everett L.(Rett) Williams was earlier kind enough to reply:<br> <dl> <dd>>rett at gvtc.com> <dd>>With this slight modification to your code for performance and proper output, <dd>>I was able to run the diehard test with the #FFFF key for rand(). The results <dd>>appeared to be pretty darn good, with some tests at both ends of the range <dd>>and many close to the middle....that is, if I understand what the results mean. <dd>>From what I see, rand should be sufficient for almost any normal purpose. <dd>>If you are really determined, you could send off for Mr. Masaglia's CDROM <dd>>with it't 60 sets of 10,000,000 random integers. By the way, the program <dd>>took about 42 seconds to generate 49,201,152 bytes.<br> <br> </dl>Yes the RNG appears to be good for everyday purposes BUT p=.500000 for all tests is the optimum. Consistant scores of p>=.9000 or p<=.10000 are not good. If the end objective of using the rand() function REQUIRES uniformly generated random numbers the results I saw did not indicate Euphoria passed all of the tests. <br> <br> Maybe RDS might like to weigh in and state the source and/or type of RNG that is coded into Euphoria.<br> <br> <br> <br> <br> Joel H. Crook<br> <br> Manager, Information Services<br> <font size=1>Certified Novell Administrator<br> Microsoft Certified Professional, OS Specialist<br> <br> </font><b>Kellogg & Andelson Accountancy Corp.<br> </b><font size=1>14724 Ventura Blvd. 2nd Floor<br> Sherman Oaks, CA 91403<br> (818) 971-5100<br> </font></html> --=====================_13980362==_.ALT--
7. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Steve Mosher <farq at KILN.ISN.NET> Feb 17, 2000
- 519 views
> Yes the RNG appears to be good for everyday purposes BUT p=.500000 for all > tests is the optimum. Consistant scores of p>=.9000 or p<=.10000 are not > good. > If the end objective of using the rand() function REQUIRES uniformly generated > random numbers the results I saw did not indicate Euphoria passed all of the > tests. > > Maybe RDS might like to weigh in and state the source and/or type of RNG that > is coded into Euphoria. From experience, don't use rand() for anything you need to be super-random -- no matter what language you're using. The best solution to an unsatisfactory level of randomness is to code your own. Hint: you can sample the time, but this is mostly only good for a seed, unless you do some interesting things to it. Have fun.
8. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Robert Craig <rds at ATTCANADA.NET> Feb 17, 2000
- 512 views
- Last edited Feb 18, 2000
Joel H. Crook writes: > Maybe RDS might like to weigh in and state the > source and/or type of RNG that is coded into Euphoria. I got the algorithm from a paper that was published about 10 years ago. The algorithm is public domain, and was claimed to have better randomness than most other algorithms of that time. Since some users depend on this algorithm for encrypting their data, I'd rather not make the details public. If you find any defects or shortcomings in rand() please let me know exactly what they are. So far all I've heard is "good for most purposes" or "doesn't measure up well on some of the (completely unspecified) tests". Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
9. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Steven G Astley <sgastley at HOTMAIL.COM> Feb 17, 2000
- 542 views
- Last edited Feb 18, 2000
Joel: if you ever get it(U4) figured out ... please share your insight. FRUSTRATED here also. ----Original Message Follows---- And some day I'll get this language figured out. Euphoria is NOT easier to code as advertised. Euphoria seems to be a cross between "wanna-don't-wanna be" ... Sorry... Just frustrated.... ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
10. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Irv Mullins <irv at ELLIJAY.COM> Feb 17, 2000
- 544 views
- Last edited Feb 18, 2000
On Thu, 17 Feb 2000, you wrote: > Irv Mullins wrote: re: > >> 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]}) vs: printf(file_number, fmt, final) Everett wrote: > Certainly, it would be theoretically faster to move the creation of fmt > outside > the loop, but any compiler with any kind of optimizing capability will take > any literal like this and treat it like a constant and move it outside the > loop. Apparently, that is what Euphoria does. There is no measurable difference in execution time between a using a constant or using a literal. (less than 1%) > The use of a variable will cause the compiler to have to check the value of > fmt every time it sees it. > The fastest way would be to create the value and > assign it to fmt as a constant. One would think so, however, there is no measurable difference between using a constant and using a sequence. Again, less than 1%. <snip> > This is probably a handicap of the aged and infirm programmer, but > complexity is oft in the eye of the beholder. It might be noted, as in the > case of COBOL, verbose does not equal complex, or even, in most cases, > less efficient. Also, with modern editors, I didn't type any of those > variable names but once...the rest was cut and paste. The advantage to > being verbose, where it does not effect performance is that it offers > the opportunity to easily alter what is written. Exception code many times > just becomes a different coding of an explicit sequence. Where the code > becomes large and untenable due to explicit coding, I will agree with your > correction. Otherwise, being straightforward has it's advantages. True again, except that the de-referencing of members of a sequence x[1], x[2],x[3].... etc, does affect performance: There's a 10 - 15% increase in execution time when applied to this list of 20. Regards, Irv
11. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Irv Mullins <irv at ELLIJAY.COM> Feb 17, 2000
- 527 views
- Last edited Feb 18, 2000
On Thu, 17 Feb 2000, you wrote: > Joel: if you ever get it(U4) figured out ... please share your insight. > FRUSTRATED here also. It would be instructive to all of us if you would give an example of a programming language you find _non-frustrating._ I've been looking for one for a long time. Regards, Irv
12. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Joel Crook <joel at MAIL.K-A.COM> Feb 17, 2000
- 514 views
At 07:10 PM 02/17/2000 -0500, you wrote: >On Thu, 17 Feb 2000, you wrote: >> Irv Mullins wrote: >> >> 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]}) >True again, except that the de-referencing of members of a sequence >x[1], x[2],x[3].... etc, does affect performance: There's a 10 - 15% increase >in execution time when applied to this list of 20. > >Regards, >Irv Irv, WHOA! Are you saying that listing "{final[ 1],final[ 2],final[ 3],final[ 4],final[ 5], final[ 6],final[ 7],final[ 8],final[ 9],final[10]})" increases the execution speed by 10 to 15 %?
13. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Everett Williams <rett at GVTC.COM> Feb 17, 2000
- 513 views
- Last edited Feb 18, 2000
Joel Crook wrote: > >Euphoria is NOT easier to code as advertised. I'm used to pascal conventions >where there are exactly two types of read and write statements not C styled >incoherance. I agree that printf, sprintf, etc. as they represent a type of language within a language are no substitute for real IO and are probably the worst documented part of Euphoria(because we are supposed to know the setup from C...I guess). Since I don't write C, they are a general pain for me. >...and Everett L.(Rett) Williams was earlier kind enough to reply: >>rett at gvtc.com> >Yes the RNG appears to be good for everyday purposes BUT p=.500000 for all >tests is the optimum. Consistant scores of p>=.9000 or p<=.10000 are not good. >If the end objective of using the rand() function REQUIRES uniformly generated >random numbers the results I saw did not indicate Euphoria passed all of the >tests. > >Maybe RDS might like to weigh in and state the source and/or type of RNG that >is coded into Euphoria. Yes it would be nice to know this and to know RDS opinion on the diehard test in general. I believe, however, that your interpretation of the results of the diehard test results are not in accordance with the writeup in the documentation, or on Mr. Masaglia's site. It says that p should be uniform on [0,1]. That means that it should average to .5 over time, but should have a uniform distribution in that range. In fact, it specifically notes that "p happens" and that only results that are 4 to six places 0 or 1 should be considered really bad. From what I could see of the results, they vary throughout that range with many values close to 1/2. If I made about a hundred runs of the diehard test with different input each time, I might be a little more comfortable with stating much of anything. Everett L.(Rett) Williams rett at gvtc.com
14. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Everett Williams <rett at GVTC.COM> Feb 17, 2000
- 525 views
- Last edited Feb 18, 2000
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. 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. Everett L.(Rett) Williams rett at gvtc.com
15. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Lewis Townsend <keroltarr at HOTMAIL.COM> Feb 18, 2000
- 543 views
Hello >From: Joel Crook <joel at MAIL.K-A.COM> >Reply-To: Euphoria Programming for MS-DOS <EUPHORIA at LISTSERV.MUOHIO.EDU> >To: EUPHORIA at LISTSERV.MUOHIO.EDU >Subject: Re: RNG Test: Code to generate Diehard file in Euphoria >Date: Thu, 17 Feb 2000 17:37:22 -0800 > >At 07:10 PM 02/17/2000 -0500, you wrote: > >On Thu, 17 Feb 2000, you wrote: > >> Irv Mullins wrote: > > >> >> 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]}) > > >True again, except that the de-referencing of members of a sequence > >x[1], x[2],x[3].... etc, does affect performance: There's a 10 - 15% >increase > >in execution time when applied to this list of 20. > > > >Regards, > >Irv > >Irv, > >WHOA! Are you saying that listing "{final[ 1],final[ 2],final[ 3],final[ >4],final[ 5], final[ 6],final[ 7],final[ 8],final[ 9],final[10]})" >increases the execution speed by 10 to 15 %? I believe he said: "increase in execution TIME" which would be a DECREASE in speed. Lewis Townsend ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
16. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Everett Williams <rett at GVTC.COM> Feb 17, 2000
- 552 views
- Last edited Feb 18, 2000
Robert Craig wrote: >Joel H. Crook writes: > >> Maybe RDS might like to weigh in and state the >> source and/or type of RNG that is coded into Euphoria. > >I got the algorithm from a paper that was published about >10 years ago. The algorithm is public domain, and was >claimed to have better randomness than most other algorithms >of that time. Since some users depend on this algorithm >for encrypting their data, I'd rather not make the details public. > >If you find any defects or shortcomings in rand() please >let me know exactly what they are. So far all I've heard >is "good for most purposes" or "doesn't measure up well >on some of the (completely unspecified) tests". If you would like to see the homepage of the Diehard test and download the DOS version that I and several others have been using, you can go to this URL http://stat.fsu.edu/~geo/diehard.html It appears to be legit. I can't see why publishing the source for your rand() would have any effect on the encrypters since you have provided a method to change the key. If the randomness is reasonable, knowing the code will give very little leverage to anyone. As I have noted in other posts, rand() appears to do quite well. Using #FFFF for a range and an atom to store into appears to produce a full 32 bit range. Everett L.(Rett) Williams rett at gvtc.com
17. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Everett Williams <rett at GVTC.COM> Feb 17, 2000
- 558 views
- Last edited Feb 18, 2000
Lewis Townsend wrote: >Hello > >> >> Irv Mullins wrote: >> >> >> >> 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]}) >> >> >True again, except that the de-referencing of members of a sequence >> >x[1], x[2],x[3].... etc, does affect performance: There's a 10 - 15% >>increase >> >in execution time when applied to this list of 20. >> > As opposed to what substituted construct is this 10-15% slower and do you mean in the whole program or in the trivial case where the loop is 2 or some such silliness. I cannot imagine a compiler so silly as to make much difference between what you see above and the printf(file_number,fmt,final) -- previously proposed code I can see that the initial interpretation of the loop might take 10-15% longer, but when spread across 600,000 iterations, who cares. Now if that really is 10-15% longer in the 600,000 case, then we've got something worth examining. Everett L.(Rett) Williams rett at gvtc.com
18. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Brian Broker <bkb at CNW.COM> Feb 17, 2000
- 499 views
- Last edited Feb 18, 2000
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)
19. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Bernie Ryan <LockCityData at CS.COM> Feb 17, 2000
- 513 views
- Last edited Feb 18, 2000
If would be real nice if one of you random experts would write a random number generator to your random specifications and place it the archive if the one in Euphoria is not precise enough to run your gambling casino that your opening next week.
20. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Irv Mullins <irv at ELLIJAY.COM> Feb 17, 2000
- 525 views
- Last edited Feb 18, 2000
Joel Crook <joel at MAIL.K-A.COM> wrote: > > And some day I'll get this language figured out. > > Euphoria is NOT easier to code as advertised. I'm used to pascal conventions > where there are exactly two types of read and write statements not C styled > incoherance. Yes, there are only two types of read and write statements. That kind of makes up for all the work you have to go thru to _get_ to the write statement: Let's see: there's Pchar, StrCat, StrMove, StrLen, StrComp, StrCopy, StrECopy, StrEnd, StrlComp, StrlCat, StrlCopy, StrLiComp, StrLower, StrNew, StrPas, StrPCopy, StrPos, StrRScan, StrScan, StrUpper, StrDispose.... Irv
21. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Brian Broker <bkb at CNW.COM> Feb 17, 2000
- 544 views
- Last edited Feb 18, 2000
Earlier I wrote (in response to Rett): >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. I also meant to say that because of the above reasoning, the program you wrote would not meet the input criteria for DieHard... -- Brian
22. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Joel Crook <joel at MAIL.K-A.COM> Feb 17, 2000
- 522 views
- Last edited Feb 18, 2000
At 08:42 PM 02/17/2000 -0500, you wrote: >If would be real nice if one of you random experts would > write a random number generator to your random specifications > and place it the archive if the one in Euphoria is not precise > enough to run your gambling casino that your opening next week. Well Bernie... that was sort of what I originally asked help on a few days ago. In C there are some real elegant (at least for C) RNGs --- ones that pass the Diehard tests but to work they require 32bit logical operators and shift_right and shift_left which U4ia does not have. See my post to the list on 2/14 entitled "More on Random Number Generators in Euphoria" Maybe I need a new tag line: I am a random programmer... Stop me before I code again!
23. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Everett Williams <rett at GVTC.COM> Feb 18, 2000
- 539 views
Brian Broker wrote: >Earlier I wrote (in response to Rett): > >>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. > >I also meant to say that because of the above reasoning, the program you >wrote would not meet the input criteria for DieHard... > >-- Brian You are absolutely right and one would think that I could count to eight by now in my career. What is really strange, is that I edited the ASCII set of numbers generated by rand(#FFFF) and they looked completely random and 32 bit. They also tested to be fairly decently random in the Diehard test. Go figure. Mr. Craig, why is this so? It is obvious that something is going on here that doesn't quite meet the eye. Also, when rereading the doc for rand(), it doesn't say that 32 bit rands can't be generated. It says that when an integer is used as range, an integer will be generated for output. It also says that this function can be applied to an atom or to all the elements of a sequence. I presume that when applied to an atom, an atom will be the result with concomitant range. I will alter the test and see what happens. Everett L.(Rett) Williams rett at gvtc.com
24. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Brian Broker <bkb at CNW.COM> Feb 18, 2000
- 527 views
On Fri, 18 Feb 2000 01:05:01 -0500, Everett Williams wrote: >numbers generated by rand(#FFFF) and they looked completely random >and 32 bit. They also tested to be fairly decently random in the Diehard >test. Go figure. Mr. Craig, why is this so? It is obvious that something is >going on here that doesn't quite meet the eye. There's really nothing 'going on' here. If you look again at your program, you will see that you are writing out 20 16-bit 'random' numbers per line, which is equivalent to 10 32-bit numbers per line (which is the format that the data conversion program wanted). Also note that rand(x1) returns an integer from 1 to x1 (so you can't get a result of #0000). Of course it will all _look_ random to the eye. After all, if rand() could return zero, then your chance of getting one with rand(#FFFF) would be 1 in 65535. This is also the reason the numbers look good to DieHard (much better than shift- left-two of a 30-bit rand). -- Brian
25. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Mark Brown <mabrown at SENET.COM.AU> Feb 18, 2000
- 532 views
- Last edited Feb 19, 2000
-----Original Message----- From: Irv Mullins <irv at ELLIJAY.COM> To: EUPHORIA at LISTSERV.MUOHIO.EDU <EUPHORIA at LISTSERV.MUOHIO.EDU> Date: Friday, February 18, 2000 11:57 AM Subject: Re: RNG Test: Code to generate Diehard file in Euphoria Irv Mullins wrote... >True again, except that the de-referencing of members of a sequence >x[1], x[2],x[3].... etc, does affect performance: There's a 10 - 15% increase >in execution time when applied to this list of 20. Hi Irv. I haven't really been following this too closely (and most of it has been over my head anyway) but the above bit caught my eye. Do you mean that referencing the elements in a sequence causes this big a performance hit ? 10 - 15% is nasty (and this sort of thing has been required a lot in the Morfit for EU api I have been working on with Todd. ) If I understand you right, is the performance hit both ways? Does it hurt just as much to put stuff into an element in a sequence as to get stuff out of it ?? I haven't noticed such a hit but I'd like to keep such things in mind if they are there. Thanks. Mark Brown
26. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Steven G Astley <sgastley at HOTMAIL.COM> Feb 18, 2000
- 532 views
Irv, you've been most helpful in getting my business application coded in U4 and i appreciate it [im about 60% done; dreading the rest, because im still not comfortable with U4's rules/syntax, documentation[lol]]. ... by definition, ALL 'languages' have their limitations/rules ... due to their inherent syntax/logic. Im NOT trying to flame anybody, but IMHO, U4 currently, is a 'hobby/game' language, w/limited capabilities to handle 'real world' applications. [Review this forum's comments.] In the 70's, i investigated developing a 'data-oriented' language like U4 and found the trade-offs to be to 'costly', for that time [perhaps thats why im trying U4 now???] Like life, a language must evolve to meet the needs [of its users] ... or perish. And RDS's 'new' challenge is making 'tough' choices: balancing performance [speed and simplicity], with functionality [ease of use and inherent capabilities]. Good luck RDS! PS: 'non frustrating programming language' ... hmmmmm ... lol... anybody remember IBM BAL? Sure 'i' had to code everything [or write a macro], but 'i' could do any/everything ... and with a minimum of concern for the language, i was 'freed' to handle the logic of the concern before me ... ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
27. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Steve Mosher <farq at KILN.ISN.NET> Feb 18, 2000
- 530 views
On Thu, 17 Feb 2000, Everett Williams wrote: > Robert Craig wrote: > > >Joel H. Crook writes: > > > >> Maybe RDS might like to weigh in and state the > >> source and/or type of RNG that is coded into Euphoria. > > > >I got the algorithm from a paper that was published about > >10 years ago. The algorithm is public domain, and was > >claimed to have better randomness than most other algorithms > >of that time. Since some users depend on this algorithm > >for encrypting their data, I'd rather not make the details public. > > > >If you find any defects or shortcomings in rand() please > >let me know exactly what they are. So far all I've heard > >is "good for most purposes" or "doesn't measure up well > >on some of the (completely unspecified) tests". > > If you would like to see the homepage of the Diehard test and download the > DOS version that I and several others have been using, you can go to this URL > > http://stat.fsu.edu/~geo/diehard.html > > It appears to be legit. > > I can't see why publishing the source for your rand() would have any effect on > the encrypters since you have provided a method to change the key. If the > randomness is reasonable, knowing the code will give very little leverage to > anyone. As I have noted in other posts, rand() appears to do quite well. Using > #FFFF for a range and an atom to store into appears to produce a full 32 bit > range. > > Everett L.(Rett) Williams > rett at gvtc.com > Aye, I agree. On top of this, the opensource community has two key phrases: 'release early, release often', and (the relevant one) 'security through obscurity isn't'. If procedural knowledge can give someone an edge, then there's something wrong with the system. Think about it, programs respond, passwords don't.
28. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Everett Williams <rett at GVTC.COM> Feb 18, 2000
- 540 views
On Fri, 18 Feb 2000 02:16:41 -0500, Brian Broker <bkb at CNW.COM> wrote: >On Fri, 18 Feb 2000 01:05:01 -0500, Everett Williams wrote: > >>numbers generated by rand(#FFFF) and they looked completely random >>and 32 bit. They also tested to be fairly decently random in the Diehard >>test. Go figure. Mr. Craig, why is this so? It is obvious that something is >>going on here that doesn't quite meet the eye. > >There's really nothing 'going on' here. If you look again at your program, >you will see that you are writing out 20 16-bit 'random' numbers per line, >which is equivalent to 10 32-bit numbers per line (which is the format that >the data conversion program wanted). Also note that rand(x1) returns an >integer from 1 to x1 (so you can't get a result of #0000). Of course it >will all _look_ random to the eye. After all, if rand() could return zero, >then your chance of getting one with rand(#FFFF) would be 1 in 65535. This >is also the reason the numbers look good to DieHard (much better than shift- >left-two of a 30-bit rand). > >-- Brian Right again. Somehow, I was looking at each rand as producing 4 bytes per execution rather than 4 hex digits per execution. It does, but the printf was pulling off the two significant bytes representing 4 hex digits per. I adjusted to fit to get the result that I wanted, but did not examine my assumption. Thanks, Everett L.(Rett) Williams rett at gvtc.com
29. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Everett Williams <rett at GVTC.COM> Feb 18, 2000
- 579 views
Everett Williams wrote: >On Fri, 18 Feb 2000 02:16:41 -0500, Brian Broker <bkb at CNW.COM> wrote: > >>On Fri, 18 Feb 2000 01:05:01 -0500, Everett Williams wrote: >> >>>numbers generated by rand(#FFFF) and they looked completely random >>>and 32 bit. They also tested to be fairly decently random in the Diehard >>>test. Go figure. Mr. Craig, why is this so? It is obvious that something is >>>going on here that doesn't quite meet the eye. >> >>There's really nothing 'going on' here. If you look again at your program, >>you will see that you are writing out 20 16-bit 'random' numbers per line, >>which is equivalent to 10 32-bit numbers per line (which is the format that >>the data conversion program wanted). Also note that rand(x1) returns an >>integer from 1 to x1 (so you can't get a result of #0000). Of course it >>will all _look_ random to the eye. After all, if rand() could return zero, >>then your chance of getting one with rand(#FFFF) would be 1 in 65535. This >>is also the reason the numbers look good to DieHard (much better than shift- >>left-two of a 30-bit rand). >> >>-- Brian > >Right again. Somehow, I was looking at each rand as producing 4 bytes per >execution rather than 4 hex digits per execution. It does, but the printf was >pulling off the two significant bytes representing 4 hex digits per. I >adjusted >to fit to get the result that I wanted, but did not examine my assumption. > P.S. I tested rand(#FFFFFFFF) and it does fail with an error message that it is out of range for an integer. Everett L.(Rett) Williams rett at gvtc.com
30. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Everett Williams <rett at GVTC.COM> Feb 18, 2000
- 507 views
Brian, Based on your corrections, I went back to two forms of the rand() output. Supposing that the range is not zero based, I used rand(#10000) - 1 as the key. This produced some 1.00000 p values on the bitstream tests in Diehard. When I went back to the rand(#FFFF) as a key, the tests produced no extreme results. This one is a bit of a mystery. Maybe you have some magic explanation for this one that I have missed. If you do not, maybe RDS does. Everett L.(Rett) Williams rett at gvtc.com
31. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Joel Crook <joel at MAIL.K-A.COM> Feb 18, 2000
- 510 views
--=====================_5163640==_.ALT At 09:58 AM 02/18/2000 -0500, you wrote: >P.S. I tested rand(#FFFFFFFF) and it does fail with an error message that >it is out of range for an integer. > >Everett L.(Rett) Williams >rett at gvtc.com It's too bad rand() must be of type integer. A note on the quirkiness of rand(#10000) vs rand(#FFFF): I seem to recall in my quest for an algorithm for a RNG that certain algorithms REQUIRED the intial seed to be odd or they would choke on the Diehard test. Joel H. Crook Manager, Information Services Certified Novell Administrator Microsoft Certified Professional, OS Specialist Kellogg & Andelson Accountancy Corp. 14724 Ventura Blvd. 2nd Floor Sherman Oaks, CA 91403 (818) 971-5100 --=====================_5163640==_.ALT <html><div>At 09:58 AM 02/18/2000 -0500, you wrote:</div> <br> <div>>P.S. I tested rand(#FFFFFFFF) and it does fail with an error message that</div> <div>>it is out of range for an integer.</div> <div>></div> <div>>Everett L.(Rett) Williams</div> <div>>rett at gvtc.com</div> <br> <div>It's too bad rand() must be of type integer. </div> <br> A note on the quirkiness of rand(#10000) vs rand(#FFFF): I seem to recall in my quest for an algorithm for a RNG that certain algorithms REQUIRED the intial seed to be odd or they would choke on the Diehard test. <br> Joel H. Crook<br> <br> Manager, Information Services<br> <font size=1>Certified Novell Administrator<br> Microsoft Certified Professional, OS Specialist<br> <br> </font><b>Kellogg & Andelson Accountancy Corp.<br> </b><font size=1>14724 Ventura Blvd. 2nd Floor<br> Sherman Oaks, CA 91403<br> (818) 971-5100<br> </font></html> --=====================_5163640==_.ALT--
32. Re: RNG Test: Code to generate Diehard file in Euphoria
- Posted by Everett Williams <rett at GVTC.COM> Feb 18, 2000
- 514 views
Joel Crook wrote: > >At 09:58 AM 02/18/2000 -0500, you wrote: > >>P.S. I tested rand(#FFFFFFFF) and it does fail with an error message that >>it is out of range for an integer. >> >>Everett L.(Rett) Williams >>rett at gvtc.com > >It's too bad rand() must be of type integer. > >A note on the quirkiness of rand(#10000) vs rand(#FFFF): I seem to recall in my >quest for an algorithm for a RNG that certain algorithms REQUIRED the intial >seed to be odd or they would choke on the Diehard test. >Joel H. Crook > I believe that you have misunderstood rand(). The integer fed to rand() is the upper bound of the range for the generated random integers. Set_rand() is the seed changing function. The way it reads, I suspect that the seed goes through some sort of transformation to meet any objections that might normally cause it to be invalid. The purpose of using rand(#10000) - 1 was to generate a #0000 thru #FFFF set instead of a #0001 thru #FFFF that is what the definition of rand() says is generated with a rand(#FFFF). Everett L.(Rett) Williams rett at gvtc.com