From:	CSBVAX::CSBVAX::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 16-FEB-1989 10:13
To:	MRGATE::"ARISIA::EVERHART"
Subj:	RE: VAX random number generator


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Thu, 16 FEB 89 06:27:16 PDT
Received: from CUNYVM.CUNY.EDU by KL.SRI.COM with TCP; Thu, 16 Feb 89 06:00:05 PST
Received: from LSUVAX.LSU.EDU by CUNYVM.CUNY.EDU (IBM VM SMTP R1.1) with BSMTP id 4929; Thu, 16 Feb 89 08:59:33 EST
Date: Wed, 15 Feb 89 18:00 CDT
From: "Michael_Jacobson, Networks Manager, L.S.U." <JACOBSON%LSUVAX.LSU.EDU@CUNYVM.CUNY.EDU>
Subject: RE: VAX random number generator
To: INFO-VAX@KL.SRI.COM
X-VMS-To: IN%"INFO-VAX@KL.SRI.COM"

We have had problems with monte-carlo calculations using vms's random number
generator. I do not understand the mathematical explination of this (Anyone
able to help out here?) but it has to do with the fact that the generated
numbers are correlated. A grad student here used the vax routine to generate
triplets of points (x,y,z) and then plotted them on a Evans & Sutherland PS300
where you can rotate the "cloud" the generated points lie in planes instead of
a nice "cloud". We "fixed" the problem by using the subroutine suggested on
p195 of "NUMERICAL RECIPES, The Art of Scientific Computing" by William H.
Press, Brian P Flannery, Saul A Teukolsky, William T. Vetterling (ISBN 0 521
30811 9). This modification seemed to be satisfactory for the calculations that
were being done here. Give it a try and see if it helps you. I have included a
copy of the routine at the end.


                                                Hope it may help,
                                                Mike Jacobson
                                                Networks Manager
                                                Louisiana State University
                                                JACOBSON@LSUVAX.BITNET
                                                LSUVAX::JACOBSON (SPAN)
--------------------------------------------------------------------------------
        FUNCTION RAN0(IDUM)
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
C Copied from NUMERICAL RECIPIES: The Art of Scientific Computing, p. 195
C
C Returns a uniform random deviate between 0.0 and 1.0 using the system supplied
C rouitine RAN(ISEED). Set IDUM to any negative value to initialize the sequence
C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
        DIMENSION V(97)
        DATA IFF /0/
        IF(IDUM.LT.0  .OR.  IFF.EQ.0) THEN
            IFF=1
            ISEED=ABS(IDUM)
            IDUM=1
C Excercise the system routine, especially important if the systems multiplier
C is small
            DO 11 J=1,97
                DUM=RAN(ISEED)
11              CONTINUE
C Now save 97 values
            DO 12 J=1,97
                V(J)=RAN(ISEED)
12              CONTINUE
            Y=RAN(ISEED)
        ENDIF
        J=1+INT(97*Y)
        IF (J.GT.97 .OR. J.LT.1) STOP "INVALID INDEX FROM RAN(ISEED)"
        Y=V(J)
        RAN0=Y
        V(J)=RAN(ISEED)
        RETURN
        END

