eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'RandomParkMiller':

Home

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

Class: RandomParkMiller


Inheritance:

   Object
   |
   +--RandomParkMiller

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

Description:


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

NO WARRANTY

Another pseudo-random number generator

The ParkMiller random generator (although better than the old Random), is not recommended 
when a high quality random is required (for example, for cryptographic work). 
Applications should use either the OS-random generator or a LaggedFibonacci generator.
This is because the random values provided by the Park-Miller generator are double precision 
floating point numbers which have up to 53 significant bits. Since only the first 31 bits 
of their mantissa are known to have good random properties, the behavior of the remaining 
22 bits is undefined. 
In particular, bit aliasing occurs during the calculation of the next random value, 
and bit 22 of the mantissa is always 1.

Please read:
    Standard reference by Park and Miller in 
        'Random Number Generators: Good Ones Are Hard to Find',
    Comm. ACM, 31:1192-1201, 1988.


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
    RandomTT800
    -
    another
    random
    generator
    RandomMT19937
    -
    a
    better
    random
    generator
    RandomKISS
    -
    fast
    and
    better
    random
    generator

Class protocol:

initialization
o  initialize
magic constant

instance creation
o  new


Instance protocol:

accessing-reading
o  next
This method generates random instances of Float in the interval 0.0 to 1.0

o  nextBoolean
This method generates a boolean

o  nextInteger
This method generates random instances of Integer in the interval 0 to 16r7FFFFFFF.

initialization
o  initialize
Set a reasonable Park-Miller starting seed

o  seed: anInteger

private
o  peek
This method answers the next random number that will be generated as a Float in the range [0..1).
It answers the same value for all successive message sends.

o  peekInteger
This method generates random instances of Integer in the interval 0 to 16r7FFFFFFF. This method does NOT update the seed; repeated sends answer the same value. The algorithm is described in detail in 'Random Number Generators: Good Ones Are Hard to Find' by Stephen K. Park and Keith W. Miller, (Comm. Asso. Comp. Mach., 31(10):1192--1201, 1988).



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 19 Apr 2024 16:19:50 GMT