random numbers in awk?

Maurice E. Suhre suhre at shark.dsd.trw.com
Tue May 14 08:18:22 AEST 1991


In article <1136 at mwtech.UUCP> martin at mwtech.UUCP (Martin Weitzel) writes:
+In article <1991Apr24.041134.14519 at athena.mit.edu> jik at athena.mit.edu (Jonathan I. Kamens) writes:
+>
+>  [...] another possibility is
+>to use the jot(1) program to generate a random number, if your system has jot.
+
+SysV User's should note that they have a similar program, called random.
+It's range of output values is restricted to 0..255 (the upper limit must
+be specified as a calling argument). If you need larger numbers, you
+can, of course, call random twice, multiply the result of the first
+call by 256, add the result of the second call, and take the whole thing
+modulo the largest number you want. 
+-- 
+Martin Weitzel, email: martin at mwtech.UUCP, voice: 49-(0)6151-6 56 83

Be advised that the operations mentioned (multiplication, modulo) will,
in general, change the distribution of the random numbers.  That is, if you
started with uniformly distributed random numbers, then what you will
come out with will not be uniformly distributed.

-- 
Maurice Suhre
suhre at trwrb.dsd.trw.com



More information about the Comp.unix.questions mailing list