home *** CD-ROM | disk | FTP | other *** search
- REAL FUNCTION URN ( KSEED )
- C
- C UNIFORM RANDOM NUMBER GENERATOR
- C X <- A*X MOD P
- C
- C WHERE
- C P = PRIME MODULUS = 2**31 - 1 = 2147483647
- C A = PRIMITIVE ROOT OF P = 7**5 = 16807
- C
- C REFERENCE
- C 'PSEUDO-RANDOM NUMBER GENERATOR FOR THE SYSTEM/360,'
- C LEWIS ET AL, IBM SYSTEM J. VOL 8 #2, 1969, PP 136-146.
- C
- C WRITTEN BY L LUCAS, CODE 3873, 4 JAN 1982
- C
- DOUBLE PRECISION DSEED, DP, DP1
- C
- DATA DP / 2147483647.D0 /
- DATA DP1 / 2147483648.D0 /
- C
- DSEED = DMOD(16807.D0*KSEED, DP)
- KSEED = DSEED
- URN = DSEED / DP1
- RETURN
- END
-