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 RandGen;

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

    Module  RandGen     (Version 1.0)

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

    Purpose   Basic pseudo-random number generator producing
              uniformly distributed variates within interval (0,1).

    Remarks   The generator is based on a combination of three
              multiplicative linear congruential random number
              generators.

              It is highly portable and produces very-long-cycle
              random-number sequences.  They exceed the usual period
              length of MAX(INTEGER) given by the machine dependent word
              length.  Thus the generator produces satisfactory results
              even on a personal computer with a small word length (e.g.
              16-Bit machines) and it is efficient, since it does not
              require double precision arithmetics.  On 32-Bit machines
              like IBM main-frames or the Apple¨ Macintoshª PC this means
              that the slow 64-Bit multiplication and division can be
              avoided.

              The cycle length of the generator is estimated to
              be > 2.78 E13 so that the sequence will not repeat
              for over 220 years in case that 1000 variates were
              calculated per second (Wichmann & Hill, 1987)

              References:

              Wichmann, B.A. & Hill, I.D., 1982.  An efficient and
                  portable pseudo-random number generator.  Algorithm
                  AS 183. Applied Statistics, 31(2): 188-190.

              Wichmann, B. & Hill, D., 1987.  Building a random-number
                 generator.  A Pascal routine for very-long-cycle
                 random-number sequences. Byte 1987(March): 127-28.


    Programming

      o Design
        Andreas Fischlin          21/12/1988

      o Implementation
        Andreas Fischlin          21/12/1988


    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:  31/08/1989  AF

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


  PROCEDURE SetSeeds(z0,z1,z2: INTEGER);
    (*defaults:  z0 = 1, z1 = 10000, z2 = 3000 *)
  PROCEDURE GetSeeds(VAR z0,z1,z2: INTEGER);
  PROCEDURE Randomize;
    (*set seeds using seed values depending on a particular, unique
    and non repeatable event in real time, e.g. date and time of
    the clock.  Implies a call to SetSeeds*)
  PROCEDURE ResetSeeds;
    (*reset seeds to values defined by last call to SetSeeds*)


  PROCEDURE U(): REAL;
    (*returns within (0,1) uniformly distributed variates*)

    (*
      Based on a combination of three multiplicative linear
      congruential random number generators of the form   z(k+1) =
      A*z(k) MOD M   with a prime modulus and a primitive root
      multiplier (=> individual generator full length period). The
      multipliers A are: 171, 172, and 170; the modulus' M are:
      30269, 30307, and 30323.
    *)


END RandGen.


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