9.3.129 RANDU (I1, I2, X)

Description:  Computes a pseudorandom number as a single-precision value.  
Class:  Subroutine 
Arguments:  I1, I2 INTEGER(2) variables or array elements that contain the seed for computing the random number. These values are updated during the computation so that they contain the updated seed. 
  X A REAL(4) variable or array element where the computed random number is returned. 
Results:  The result is returned in X, which must be of type REAL(4). The result value is a pseudorandom number in the range 0.0 to 1.0. The algorithm for computing the random number value is based on the values for I1 and I2.

If I1=0 and I2=0, the generator base is set as follows:
   X(n + 1) = 2**16 + 3
Otherwise, it is set as follows:
   X(n + 1) = (2**16 + 3) * X(n) mod 2**32
The generator base X(n + 1) is stored in I1, I2. The result is X(n + 1) scaled to a real value Y(n + 1), for 0.0 <= Y(n + 1) < 1. 

Examples

Consider the following:

REAL X
INTEGER(2) I, J
...
CALL RANDU (I, J, X)

If I and J are values 4 and 6, X stores the value 5.4932479E-04.


Previous Page Next Page Table of Contents