ETHZ_Logo RAMSES_Logo_Right   RAMSES   RAMSES_Logo_Left Systems Ecology  
Start    search button      Modules:   A-Z   Function   Layer        QuickRefs:   DM   AuxLib   AuxLibE   SciLib   EasyMW   MW   ISIS   RMSLib

DEFINITION MODULE Randoms;

  (*******************************************************************

    Module  Randoms     (Version 1.0)

      Copyright (c) 1998-2006 by Andreas Fischlin and ETH Zurich.

    Purpose   Implements a multiplicative linear congruential
              random number generator.

    Remarks   z(k+1) = A*z(k) MOD M

              Multiplier A as well as modulus M are nonnegative
              integers.  A and M should satisfy in minimum these
              conditions: A and M should be relatively prime, M should
              be an odd prime, and A should be a primitive root of M.
              These criteria warrant full period M.

                M = 2**31 - 1 = 2147483647 = MAX(LONGINT)

                A = 950'706'376       default multiplier

              Above value of A is according to Fishman & Moore (1984)
              the best there is for this type of random number
              generator with maximum modulus M (for 32 bit integer
              arithmetic) and warranted full period.  The author's
              exhaustive analysis of the statistical properties of this
              generator have resulted in other possible multipliers,
              having been ranked as the best 5, however, according to
              the authors of slightly lesser random quality than A =
              950706376.  The 5 best are

                              A
                  -------------
                    950'706'376    The very "best" of the 5 best
                    742'938'285
                  1'226'874'159
                     62'089'911
                  1'343'714'438    The least "best" of the 5 best
                  -------------

              out of 534 Million candidates for A!  A first empirical
              selection criterion has still left 414 top candidates,
              out of which above 5 have excelled.

              Implementation restriction: This module does not allow
              for changing the modulus M, which should be of little
              concern, since M = MAX(LONGINT) warrants the largest
              possible period for 32 bit integer arithmetics.

              References:

              G. Fishman & L.R. Moore III, 1982. A statistical
                evaluation of multiplicative congruential random
                number generators with modulus 2^31-1.  J.  Amer.
                Statist.  Assoc., 77: 129ff.

              G. Fishman & L.R. Moore III, 1984. An exhaustive
¤                analysis of multiplicative congruential ranom
                number generators with modulus 2**31 -1.
                Technical report UNC/ORSA/TR-84/5,44pp.


    Programming

      o Design
        Andreas Fischlin          22/02/1998

      o Implementation
        Andreas Fischlin          22/02/1998


    ETH Zurich
    Systems Ecology
    CHN E 35.1
    Universitaetstrasse 16
    8092 Zurich
    SWITZERLAND

    URLs:
        <mailto:RAMSES@env.ethz.ch>
        <http://www.sysecol.ethz.ch>
        <http://www.sysecol.ethz.ch/SimSoftware/RAMSES>


    Last revision of definition:  25/02/1998  AF

  *******************************************************************)


  PROCEDURE SetMultiplier(multiplierA: LONGINT);
  (* See remarks above *)

  PROCEDURE Seed(z0: LONGINT); (*default z0 = 1*)
  PROCEDURE GetZ(VAR curz: LONGINT);
  (* Returns last z, e.g. for reseeding U in subsequent simulations *)
  	
  PROCEDURE U(): REAL;
  (* returns within (0,1] uniformly distributed variates *)

END Randoms.

  Contact RAMSES@env.ethz.ch Last updated: 25-Jul-2011 [Top of page]