home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / math / ultra101 / readme < prev    next >
Encoding:
Text File  |  1992-03-26  |  7.4 KB  |  186 lines

  1. The following is a description of a random number package written
  2. for the 8086 family in assembler. An inefficient but easy to understand
  3. algorithm written in C implementing the same generator is also
  4. included for those who wish to port it to other architectures.
  5. There seem to be all the good properties that one could ask for
  6. in a generator here, while the speed is comparable to the fastest
  7. generators:
  8.  
  9.  Program:    ULTRA
  10.  
  11.  Description:    The greatest random number generator that ever was
  12.         or ever will be.  Way beyond Super-Duper.
  13.         (Just kidding, but we think its a good one.)
  14.  
  15.  Authors:    Arif Zaman (arif@stat.fsu.edu) and
  16.         George Marsaglia (geo@stat.fsu.edu).
  17.  
  18.  Date:        18 March 1992
  19.  
  20.  Version:    1.01
  21.  
  22.  Copyright:    To obtain permission to incorporate this program into
  23.         any commercial product, please contact the authors at
  24.         the e-mail address given above or at
  25.  
  26.         Department of Statistics and
  27.         Supercomputer Computations Research Institute
  28.         Florida State University
  29.         Tallahassee, FL 32306.
  30.  
  31.  
  32. ----------------------------------------------------------------------
  33.  DETAILED DESCRIPTION:
  34.  
  35.  This is an implementation of a random number generator with many
  36.  good properties that common generators lack, namely:
  37.  
  38.      o  Extremely long period (more than 10^356---that's more than
  39.         10^270 numbers for each atom in the universe, in case you
  40.          want to simulate creation).
  41.  
  42.      o  Combines two different types of generators, to achieve a very
  43.         thorough mixing.
  44.  
  45.      o  Very fast.
  46.  
  47.      o  Random bits, bytes, 16 or 32 bit words, single or double precision
  48.         real numbers are all available.
  49.  
  50.      o  Single precision reals (by far the most common) are guaranteed
  51.         to have full precision in the fraction (mantissa).
  52.         Almost all generators  produce reals by dividing a 32 (or 31) bit
  53.         integer by 2^32 (2^31).  This means the smallest possible
  54.         random reals are small multiples of 2^(-32).  This implementation
  55.         will produce random reals down to 2^(-50) or smaller with the proper
  56.         frequencies.  This makes it impossible to get a 0, which
  57.         avoids the rare, but irritating program-stopping situation
  58.         that arises from taking a logarithm of, or dividing by, zero.
  59.  
  60.  The principal component of ULTRA is the Subtract-with-Borrow (SWB)
  61.  generator that is described in our paper `A New Class of Random Number
  62.  Generators', Annals of Applied Probability V1 462-480, 1991.
  63.  This uses a 148 byte seed array, to obtain an astronomically large
  64.  period, while satisfying all the usual theoretical and experimental
  65.  tests for randomness.
  66.  
  67.  The other component of ULTRA is the congruential generator with
  68.  multiplier 69069 and base 2^32. This is a very well known, reliable
  69.  (but short period) generator, tried and tested. It is, for example,
  70.  the generator built into VAX's. The results of both of these
  71.  generators are xor'ed to provide the bytes which form the output
  72.  of the ULTRA random number generator.
  73.  
  74. ----------------------------------------------------------------------
  75.  
  76.  FUNCTIONS and SUBROUTINES
  77.  
  78.   The i[n]bit functions:
  79.   ---------------------
  80.     i1bit(), i7bit(), i8bit(), i15bit(), i16bit(), i31bit(), i32bit()
  81.  
  82.     For n=32, 16, 8 these return a 4, 2, 1 byte answer which has
  83.     all bits random, hence is a random integer. If it is treated
  84.     as a signed integer, it ranges from -2^(n-1) to 2^(n-1)-1.
  85.     As an unsigned integer it range is 0 to 2^n-1.
  86.  
  87.     For n=31, 15, 7 these return a 4, 2, 1 byte answer, but since
  88.     the sign bit is always off, these are always positive integers
  89.     from 0 and 2^n-1.
  90.  
  91.   [d][u/v]ni functions:
  92.   --------------------
  93.     uni(), vni(), duni(), dvni()
  94.  
  95.     uni() is a single precision uniform random number strictly
  96.      between 0 and 1.  uni() always has 24 bits of precision;
  97.      it will never be 0 (or 1).
  98.  
  99.     vni() is a single precision uniform between -1 and 1. It always has
  100.           24 bits of precision, and it never takes on the extreme values.
  101.  
  102.     duni() and dvni() are double precision version of uni and vni.
  103.           They have no more than 64 bits of precision.
  104.  
  105.   rinit(n1,n2):
  106.   ------------
  107.     Calling rinit(n1,n2) initializes the seed array, using
  108.     the two 32-bit integer arguments n1 and n2.
  109.     The first argument should be odd (if it isn't it is made so).
  110.     If rinit is not called, the built-in default state is
  111.     what would result from the call rinit(1234567,7654321).
  112.  
  113. =======================================================================
  114.  
  115. Contents of this package:
  116.  
  117.   readme    - This file
  118.   ultra.doc    - An explanation of the structure of the following
  119.           assmbeler programs. Linkage and Compilation
  120.           instructions and internal details can be found here.
  121.  
  122.   ultra_c.asm    - A Turbo C header file
  123.   ultra_lh.asm    - A Lahey Fortran header file
  124.   ultra_fr.asm    - An IBM Fortran/2 header file
  125.   ultra_tp.asm    - A Turbo Pascal header file
  126.  
  127.   ultracod.inc    - The assmebler implementation of the Ultra
  128.   ultradat.inc      random number generator. To use any high level
  129.           language is simply a matter of changing the 
  130.           header file.
  131.  
  132.   ult32_c.asm    - These four files are just like the above four
  133.   ult32_lh.asm    - but they will work on 80386 and above processors.
  134.   ult32_tp.asm    - They use the 32bit instructions to get more speed.
  135.   ult32_fr.asm------This file doesn't work see note at the end.
  136.   ult32cod.inc
  137.   ult32dat.inc
  138.  
  139.   ultratpu.pas    - A program to make Turbo Pascal units. See it or the
  140.           makefile for an explanation of switches to make
  141.           ultra.tpu or ultra32.tpu
  142.  
  143.   demo.c    - Programs to exercise the various parts of ultra.asm
  144.   demo.pas    - and verify that the output remains unchanged. The
  145.   demo.for    - 'correct' output is contained in the file demo.out.
  146.  
  147.   ultra.c    - The same program as the assembler version written
  148.           very inefficiently in C. This is only to allow
  149.           programmers inexperienced with 80x86 assembley
  150.           language to understand the alogrithm.
  151.           We hope this will encourage others to implement
  152.           the algorithm on other hardware platforms.
  153.           If you do, please report it to us.
  154.  
  155.   demo.out    - The output from demo.c linked with ultra.c
  156.   makefile    - A makefile (for the Borland MAKE program) which compiles
  157.           all the .obj files on my machine. It will almost certainly
  158.           have to be modified for any other machine. You can use it
  159.           as an example of the comilation switches needed.
  160.   dif        - A comparison of outputs from all the various demos.
  161.           Turbo C tiny model seems to mess up its output for some
  162.           reason. The Fortran output seems to round the last digit
  163.           differently for the floating point part. Otherwise it
  164.           all seems to work. IBM fortran/2 doesn't link correctly
  165.           with ULT32 for some reason (see note at the end).
  166.  
  167. Compiled object codes for several languages:
  168.  
  169.   ultra_fr.obj    - IBM Fortran/2
  170.   ultra_lh.obj    - Lahey Fortran
  171.   ultra_ct.obj    - Turbo C (Tiny model)
  172.   ultra_cs.obj    - Tubro C (Small model)
  173.   ultra_cm.obj    - Turbo C (Medium model)
  174.   ultra_cc.obj    - Turbo C (Compact model)
  175.   ultra_cl.obj    - Turbo C (Large model)
  176.   ultra_ch.obj    - Turbo C (Huge model)
  177.  
  178.   ult32-??.obj  - are 80386/80486 versions of the same libraries.
  179.  
  180.   ultra.tpu    - Turbo Pascal 6.0 TPU
  181.   ultra32.tpu    - 80386/80486 version of above.
  182.  
  183. NOTE:    My computer crashes when I run the demo with ult32_fr (the
  184.     32 bit version for IBM Fortran/2). I include it for whoever
  185.     wants to fix it.
  186.