ftp.nice.ch/pub/next/science/mathematics/Random.2.0.N.bs.tar.gz#/Random2.0/Documentation

Classes/
 
README.Architecture.rtf
[View README.Architecture.rtf] 
README.Features
 
README.Tests.rtf
[View README.Tests.rtf] 
README.Usage.txt
[View README.Usage.txt] 

README.Architecture.rtf


Random Architecture

Version 2.0

By Gregor N. Purdy

Copyright (C) 1991, 1992 Contemporary Design Studios. All rights reserved.
____________________


The architecture of the Random system is really fairly simple. The main departure from typical systems is that Random doesn't force you to use any one random number generator. This allows you the freedom to choose the tradeoffs you need to make for a given application between speed and degree of randomness.

To allow you to use whatever pseudo-random number generation algorithm you choose, Random provides an abstract superclass called RandomEngine. Any time you instantiate a Random instance or an instance of one of its subclasses, you either specify a subclass of RandomEngine or RandomEngine itself as the class of generator to use, or you can specify an instance of one of these classes. Any operation you perform through the Random instance will then use the random number generator you provided.

The random class keeps two data buffers: One for bits and one for bytes. When the Random instance is initialized, the buffers are filled with the generator's output, whatever size that may be. Then, during usage, byte-sized chunks of random bits are used from the byte buffer, and bit-sized chunks are used from the bit buffer. This means that it is less expensive to ask for a boolean value than it is to ask for some 32-bit quantity, since the bit comes from the bit buffer, instead of the byte buffer.

Another feature of the Random class is that the percent method fills its result double with 52 random bits for the fraction, instead of starting with a random 32 bit quantity and dividing by the maximum 32 bit value. This provides finer granularity in random floating-point values than was previously available.

All classes included in the Random System are capable of archiving themselves, just as you would expect from any other AppKit-compatible classes. This allows you to save the entire state of your random number geration system, without regard for the details of any of the implementations.

The interface for the RandomEngine class is very simple, and you will find it easy to implement your own random number generators. All you do is implement four methods in your new class.

The class method +unit is used by Random to determine how large its buffers should be. Whatever the natural size of the value your generator makes (in multiples of whole bytes), just have +unit return it.

Implement the ±makeRandom: instance method to do whatever is necessary to generate the next value in the sequence and stuff it into the buffer location provided.

Implement the ±read: and ±write: methods for archiving, so your class can save and restore its state.

____________________

README.Features

----------------------------------------------------------------------

Random

Version 2.0
1992 May 29

Written by Gregor N. Purdy
gregor@umich.edu

Copyright (C) 1191, 1992 Contemporary Design Studios.
All rights reserved.

----------------------------------------------------------------------

New features since 1.1:
    *	New extensible architecture separating pseudo-random bit
    	generation from interpretation (as BOOL, double, etc.).
    *	Additional engines: R250Engine, StandardEngine.
    *	More efficient use of bits (see randMin:Max: in Random).
    *	Better percent method (potentially non-portable, though. See
    	Random).
    *	More testing programs.
    *	Two new graphical demos: RandPlot and RandHist.


New features since 1.0:

    *	Gaussian variables;
    *	Arbitrary distribution (via randFunc: method);
    *	Nicer distribution policy;
    *	Two neat histogram testing programs, one for flat distributions
    	(from percent method), and one for Gaussian distributions (from
	gaussian method).


----------------------------------------------------------------------

README.Tests.rtf


Random Tests

Version 2.0

By Gregor N. Purdy

Copyright (C) 1991, 1992 Contemporary Design Studios. All rights reserved.
____________________


Included in the Random distribution are four test programs. A quick description of each is included below.

TestArchive

This program exercises the Random classes by putting each RandomEngine subclass through the following test: Generate 1000 random percentages; archive to a file; generate and save in an array 1000 more; read the engine back in from the file; generate 1000 more random percentages and compare them to those saved in the array.

TestDieRoller

This program exercises the Random classes by making them generate a number of 20-sided-die rolls , and prints a summary of the results. It only uses the ElkinsEngine.

TestGaussian

This program exercises the Random classes by making them generate a number of gaussian variables, and graphs a (textual) histogram of the results.

TestPercent

This program exercises the Random classes by making them generate a number of percentages (values between 0.0 and 1.0, inclusive), and graphs a (textual) histogram of the results.

____________________

README.Usage.txt

----------------------------------------------------------------------

Random

Version 2.0
1992 May 29

Written by Gregor N. Purdy
gregor@umich.edu

Copyright (C) 1991, 1992 Contemporary Design Studios.
All rights reserved.

----------------------------------------------------------------------

THIS WORK IS DISTRIBUTED AS IS, WITH NO WARANTEE OR GUARANTEE EXPRESSED OR
IMPLIED IN ANY RESPECT. THE AUTHOR IS NOT LIABLE FOR ANY DAMAGES WHATSOEVER
DIRECTLY OR INDIRECTLY RELATED TO THE USAGE OF THIS WORK.

That said, I do welcome comments, suggestions, and bug reports. I want to
use this in some of my own projects, so I'm very interested in making sure
it works correctly. Feel free to drop me an email or letter with your
comments.

This work is distributed as FreeWare. Previous versions were further
restricted under the GNU Public License, version 1. This version is no
longer so restricted.

This version of the Random class may be used by anyone, anywhere, for
anything, with the following conditions:

	(i)	The usage must not be illegal in any way.
	(ii)	You must credit Contemporary Design Studios and
		Gregor N. Purdy and include the copyright information at
		the top of this document in your documentation and in your
		"Info Panel," if any, if your work is ever used by anyone
		other than yourself.
	(iii)	Contemporary Design Studios and Gregor N. Purdy retain the
		right to make improvements to this work and to change the
		distribution conditions and terms in future versions.
	(iv)	You may NOT in any way change the Random class and
		redistribute it, even under a new name, but you MAY, and in
		fact are encouraged to, report bugs and make suggestions for
		enhancements to Contemporary Design Studios and
		Gregor N. Purdy.
	(iv)	You MAY make subclasses of Random that do whatever you want.
		Of course, these subclasses will be governed by your own
		rules, but the Random class will still be governed by these
		rules.
	(v)	You MAY distribute the source code of the Random class with
		your work, but all the documentation for Random, including
		this notice, must be distributed with it. Nobody should ever
		see the source code to the Random class without also seeing
		these documentation files, so they can use it, too.


----------------------------------------------------------------------

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.