🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #1362

Re: ARexx psuedo-random number generator

#1362
From: Steve Walton
Date: Thu, 21 Sep 1989 05:16
27 lines
2002 bytes
In article <1989Sep13.032352.10321@agate.berkeley.edu> mwm@eris.berkeley.edu (Mike (I'll think of something yet) Meyer) writes:
>As a general rule, serious applications should never use the random
>number generator provided with a language...
>"The Art of Computer Programming" vol.  2 - "Seminumerical Algorithms"
>- is the canonical reference,

Well, I find Knuth pretty tough sledding.  I'm not sure one can make
such a "general rule."  One advantage of a language's included generator
is that it is (usually) fast.  A trick recommended by the authors of
_Numerical Recipes_ (in addition to their own, portable generators) is to
"scramble " your generator by calling it twice;  the first time is
used as an index to an array of numbers from the generator.  In ARexx
this might be:

if (firsttime) then		/* Initialize table. */
do i=1 to 97			/* Exact value 97 is unimportant. */
   table.i = randu()		/* Fill table with random values. */
end
j = random(1, 97)		/* Random index into table. */
returnvalue = table.j		/* Return that table location. */
table.j = randu()		/* Refill table entry. */
return returnvalue

NumRecs says that this should do well unless your generator is a real botch.

Steve Walton, normally ecphssrw@afws.csun.edu
[Anyone know of a Unix guru willing to work at CSUN?]
Technical Details
Message-ID: <12003@cit-vax.Caltech.Edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!cit-vax!tybalt.caltech.edu!walton
References: <19504@unix.cis.pitt.edu> <1989Sep13.032352.10321@agate.berkeley.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!cit-vax!tybalt.caltech.edu!walton
From: walton@tybalt.caltech.edu (Steve Walton)
Newsgroups: comp.sys.amiga.tech
Subject: Re: ARexx psuedo-random number generator
Summary: ARexx source for a scrambler for randu()
Keywords: ARexx Random Number Generator
Message-ID: <12003@cit-vax.Caltech.Edu>
Date: 21 Sep 89 05:16:21 GMT
References: <19504@unix.cis.pitt.edu> <1989Sep13.032352.10321@agate.berkeley.edu>
Sender: news@cit-vax.Caltech.Edu
Reply-To: walton@tybalt.caltech.edu.UUCP (Steve Walton)
Organization: California Institute of Technology
Lines: 27