eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'RandomTT800':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: RandomTT800


Inheritance:

   Object
   |
   +--RandomTT800

Package:
stx:libbasic2
Category:
Magnitude-Numbers-Random
Version:
rev: 1.12 date: 2018/03/02 13:04:19
user: cg
file: RandomTT800.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


Warning: this generator should not be used for cryptographic work.

NO WARRANTY

Slightly adapted Squeak code for fileIn into ST/X.
The original comment was:


A pseudo-random number generator; see below for references.
This generator is much slower than Squeak's Random class.
It automatically seeds itself based on the millisecond clock.

Using the generator:

        randy := RandomTT800 new.
        randy seed: anInteger. 'optional; never use zero'
        aRandom := randy next.

Example (InspectIt):

        | r |
        r := RandomTT800 new.
        (1 to: 50) collect: [ :n | r next ].

===================================================================

Originally a C-program for TT800 : July 8th 1996 Version
by M. Matsumoto, email: matumoto@math.keio.ac.jp

Generates one pseudorandom number with double precision which is uniformly distributed 
on [0,1]-interval for each call.  One may choose any initial 25 seeds except all zeros.

See: ACM Transactions on Modelling and Computer Simulation,
Vol. 4, No. 3, 1994, pages 254-266.

ABSTRACT 

The twisted GFSR generators proposed in a previous article have a defect in k-distribution for k larger 
than the order of recurrence. 
In this follow up article, we introduce and analyze a new TGFSR variant having better k-distribution property. 
We provide an efficient algorithm to obtain the order of equidistribution, together with a tight upper bound 
on the order. 
We discuss a method to search for generators attaining this bound, and we list some of these such generators. 
The upper bound turns out to be (sometimes far) less than the maximum order of equidistribution for a generator 
of that period length, but far more than that for a GFSR with a working are of the same size.

Previous paper:

ACM Transactions on Modeling and Computer Simulation 
Volume 2 , Issue 3 (1992) Pages 179-194 
Twisted GFSR generators 
Makoto Matsumoto, and Yoshiharu Kurita 

ABSTRACT 

The generalized feed back shift register (GFSR) algorithm suggested by Lewis and Payne is a widely used pseudorandom number generator, but has the following serious drawbacks: (1) an initialization scheme to assure higher order equidistribution is involved and is time consuming; (2) each bit of the
generated words constitutes an m-sequence based on a primitive trinomials, which shows poor randomness with respect to weight distribution; (3) a large working area is necessary; (4) the period of sequence is far shorter than the theoretical upper bound. This paper presents the twisted GFSR (TGFSR) algorithm, a slightly but essentially modified version of the GFSR, which solves all the above problems without loss of merit. Some practical TGFSR generators were implemented and passed strict empirical tests. These new generators are most suitable for simulation of a large distributive system, which requires a number of mutually independent pseudorandom number generators with compact size.


Related information:

    http://www0.cs.ucl.ac.uk/staff/d.jones/GoodPracticeRNG.pdf
    RandomGenerator
    -
    the
    default;
    uses
    the
    machine's
    /dev/random
    if
    available
    Random
    -
    fast,
    but
    generates
    less
    quality
    random
    numbers
    RandomParkMiller
    -
    a
    good
    one
    (according
    to
    literature)
    RandomMT19973
    -
    a
    better
    one
    (according
    to
    literature)
    RandomKISS
    -
    a
    fast,
    reasonably
    good
    one
    (according
    to
    literature)

Class protocol:

initialization
o  initialSeeds
initial 25 seeds, change as you wish. (there must be N seeds)

o  originalSeeds
original initial 25 seeds. DO NOT CHANGE

instantiation
o  new

testing
o  bucketTest1
Answers an array with 50 elements each of which should hold an integer near the value 1000,
the closer the better.
usage example(s):
RandomTT800 bucketTest1 inspect 

o  firstInteger: s
Answers an array with the first 's' raw integer elements generated by the RNG using the original seeds.
Intended for testing only.
usage example(s):
RandomTT800 firstInteger: 50 

o  theItsCompletelyBrokenTest
Test to see if generator is answering what it should.
Assumes that the initial seeds are what is given in the original version.
If this fails something is badly wrong; do not use this generator.
usage example(s):
RandomTT800 theItsCompletelyBrokenTest 


Instance protocol:

initialization
o  initialize
x := self class initialSeeds. (Done in #seed:)

o  seed: anInteger

o  setSeeds: anArray
Used only by class methods for testing.

random numbers
o  next
Answer the next random number as a float in the range [0.0,1.0)

o  nextBoolean
Answer the next boolean

o  nextInteger
Answer the next random number in its raw integer form


Examples:


    | r |
    r := RandomTT800 new.
    (1 to: 50) collect: [ :n | r next ].


ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Sat, 17 Nov 2018 08:50:10 GMT