Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!lll-lcc!seismo!rochester!cornell!batcomputer!braner From: braner@batcomputer.UUCP Newsgroups: sci.math,sci.physics,sci.crypt,sci.math.stat Subject: Re: Do you use RANDOM NUMBERS? Message-ID: <464@batcomputer.tn.cornell.edu> Date: Fri, 20-Mar-87 16:14:25 EST Article-I.D.: batcompu.464 Posted: Fri Mar 20 16:14:25 1987 Date-Received: Thu, 26-Mar-87 04:40:04 EST References: <5712@reed.UUCP> Reply-To: braner@batcomputer.UUCP (braner) Organization: Theory Center, Cornell University, Ithaca NY Lines: 28 Keywords: Random numbers, leprechauns Xref: utgpu sci.math:761 sci.physics:950 sci.crypt:256 sci.math.stat:83 Summary: Autocorr's is what worries me. I use my own AL routine. [] In some simulations I do I need _MANY_ random numbers (say 1E8 numbers...), and calculating them _IS_ a major portion of the program run time (especially if I need nonuniform numbers, e.g. lognormal). I worry mostly about them being autocorrelated, a common flaw in simple-minded generators. I currently use home-made assembly-language routines (for the 68000 chip). My basic uniform generator yields a 32-bit random integer in about 36 microsec (_including_ the overhead of calling from a high-level language and returning the value into a variable in that language). Other AL routines return floating-point results that are either uniform (60 usec), approximately normal, exponential, or lognormal (about 100-200 usec for these). (All timings with an 8 Mhz CPU.) My generator has limited resolution (32 bits), hence not very good in the extreme tails. And the transcendental functions are implemented using look-up tables, for speed rather than accuracy. But the basic generator passed all the uniformity and autocorrelation tests I could devise. I recommend using integer rather than FP randoms in simulations whenever possible, for speed. E.g., to simulate an event that happens with prob p (a constant), calculate "intp = (integer) (K*p)" _outside_ the loop, and use "if random() < intp then do it" inside the loop. (K is 2^32, or whatever fits your _integer_ random() generator.) (Those of you for whom all this is boring, obvious, old-hat stuff, please forgive me...) - Moshe Braner