V104: Uniform Random Numbers

Author(s): CDC: H. von Eicken, IBM: T. Lindelöf Library: KERNLIB
Submitter: Submitted: 07.12.1970
Language: Assembler Revised: 15.09.1978

tex2html_wrap144

RNDM generates uniformly distributed pseudo-random numbers in the interval (0,1) in type REAL and in the interval tex2html_wrap_inline106 (CDC) or tex2html_wrap_inline108 (IBM) in type INTEGER. The CDC version has a period of more than tex2html_wrap_inline110 . The IBM period, however, is only about tex2html_wrap_inline112 which may not be good enough for some calculations. In that case RNDM2 (V107) should be used instead.

Structure:

SUBROUTINE subprogram
User Entry Names: IRNDM, RNDM, RDMIN, RDMOUT

Usage:

    Y = RNDM(X)
where X is a dummy argument (see Notes), sets Y to a pseudo-random number in the interval (0,1). X and Y are of type REAL.
    I = IRNDM(X)
where X is a dummy argument (see Notes), sets I to an integer pseudo-random number in the interval tex2html_wrap_inline114 on CDC, tex2html_wrap_inline116 on IBM. X is of type REAL and I is of type INTEGER.
    CALL RDMOUT(SEED)
replaces SEED by the current value of the integer pseudo-random number. This SEED may then be used to restart the sequence at this point, by a call to RDMIN. SEED is of type REAL.
    CALL RDMIN(SEED)
replaces the current value of the integer pseudo-random number by the value of the variable SEED. SEED is of type REAL. The value of SEED should not be chosen by the user but should be obtained by a previous call to RDMOUT. If this is not complied with, the numbers generated may have serious defects in their randomness.

Method:

CDC:
Consider the sequence:

eqnarray84

where tex2html_wrap_inline118 and tex2html_wrap_inline120 are the unnormalised floating-point representation of the starting number and tex2html_wrap_inline122 respectively. The j-th floating-point number tex2html_wrap_inline126 is obtained by packing tex2html_wrap_inline128 with an exponent (-47) and normalising it. This ensures that tex2html_wrap_inline132 falls in the interval (0,1).

The product tex2html_wrap_inline134 is generated in a 96 bit accumulator. The integer number tex2html_wrap_inline136 returned is the low order 47 bits of the contents of this accumulator, except that the right-most 11 bits are replaced by those occupying bit positions 48-58. This replacement is done in order to increase the time period of the low order bits.
IBM: See write-up for RNDM2 (V107).

Notes:

While the argument is dummy, in the sense that the generator makes no use of it, it must be noted that if a reference to RNDM occurs

tex2html_wrap_inline138
more than once within a Fortran statement, the argument to it should be different in each case;
tex2html_wrap_inline140
in a DO-loop, the argument must depend either directly or indirectly on the index of this loop.
These rules must be observed since the compilers, in their attempt to optimise the object code, assume that functions called with identical arguments return the same function value.
tex2html_wrap_inline142

Michel Goossens Wed Jun 5 08:27:06 METDST 1996