previous up next print clean
Next: Normal distribution Up: APPENDIX: SOME FORTRAN SUBROUTINES Previous: An alternative to Schrage

Uniform distribution

      SUBROUTINE sub4(npts,seed,output)

      INTEGER npts,seed
      REAL output(npts)

      INTEGER magic1,magic2,temp,j
      REAL alfa,beta

      magic1 = 727
      magic2 = 2**19 - 1
      beta = 1.0/FLOAT(magic2 - 1)
      alfa = - beta/2.0
      temp = seed
      DO j = 1,npts
         output(j) = alfa + beta*FLOAT(temp)
         temp= MOD(magic1*temp,magic2)
      END DO
      seed = temp

      RETURN
      END


Stanford Exploration Project
11/18/1997