
Class: RandomTT800
Object

+RandomTT800
 Package:
 stx:libbasic2
 Category:
 MagnitudeNumbersRandom
 Version:
 rev:
1.12
date: 2018/03/02 13:04:19
 user: cg
 file: RandomTT800.st directory: libbasic2
 module: stx stcclassLibrary: libbasic2
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 pseudorandom 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 Cprogram 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 254266.
ABSTRACT
The twisted GFSR generators proposed in a previous article have a defect in kdistribution for k larger
than the order of recurrence.
In this follow up article, we introduce and analyze a new TGFSR variant having better kdistribution 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 179194
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 msequence 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.
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)
initialization

initialSeeds

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

originalSeeds

original initial 25 seeds. DO NOT CHANGE
instantiation

new

testing

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


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


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

initialization

initialize

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

seed: anInteger


setSeeds: anArray

Used only by class methods for testing.
random numbers

next

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

nextBoolean

Answer the next boolean

nextInteger

Answer the next random number in its raw integer form
 r 
r := RandomTT800 new.
(1 to: 50) collect: [ :n  r next ].

