Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!um-math!sharkey!cfctech!teemc!hpftc!zardoz!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!usc!cs.utexas.edu!rutgers!columbia!sylvester!ari
From: ari@sylvester (Ari Gross)
Newsgroups: comp.sys.ibm.pc
Subject: Stuck on pc random number generation : help
Keywords: beta testing
Message-ID: <6474@columbia.edu>
Date: 30 Aug 89 20:51:33 GMT
References: <7561@microsoft.UUCP> <1991@leah.Albany.Edu>
Sender: news@columbia.edu
Reply-To: ari@sylvester.UUCP (Ari Gross)
Distribution: usa
Organization: Columbia University CS Department
Lines: 27

Here is some Fortran code for generating random numbers.

subroutine randu(ix, iy, yfl)
iy = ix*65539
if (iy) 5, 6, 6
5    iy = iy + 2147483647 + 1
6    yfl = iy
     yfl = yfl*(.4656613e-9)
     return

The number 65539 is prime and is used to continue generating
random numbers, since when this number overflows the lower
order are taken (which should be fairly random).

It ran on the IBM mainframe, but when tried on the PC
it fails to deliver. The difference seems to be in the way
the machine handle an overflow condition, which naturally
happens when this code is called repeatedly (to say generate
a gauss distribution random number).
Any suggestions as to how the code can be modified, or does anyone have
some fortran code that DOES generate random numbers for the PC 
(uniformly or gaussian distribution) ???


Ari Gross
Columbia University CS
ari@cs.columbia.edu