The randomX package for Java
The randomX package is an upward compatible superset
of the standard Java API class java.util.Random. Unlike
the standard Random class, randomX defines
an abstract superclass which supports derived classes based on a
variety of random and pseudorandom byte stream generators. The
derived class need only supply methods to construct a new generator
and return successive bytes; randomX provides all the
higher level functionality of the standard Java Random
class. (A derived class is, of course, free to override
randomX's implementation of the higher level methods,
where appropriate.)
When performing Monte Carlo calculations or simulations driven by pseudorandom sequences, there's always a lingering worry that the results may have been biased by subtle regularities in the generator's output. One excellent way to assuage such anxiety is to reproduce the results using a different generator, also reputed to be of high quality, but based on a totally different underlying algorithm. Even if one or even both of the generators exhibits some significant regularity in their output, is it unlikely in the extreme they would both depart from randomness in the same manner as to yield the same bias in the result.
randomX makes switching among different randomisation
sources as easy as changing a single declaration in a program.
Further, the randomX framework minimises the work involved
in adding a new generator to the library. The high-level access to
the Internet provided by the java.net package makes it
simple to provide a randomX-derived object which returns
genuine random data from the HotBits server.
This allows you to develop your program using repeatable pseudorandom
sequences which permit repeatable operation during the debugging
phase, then switch to true random numbers after the program
is working correctly.
The following classes are included in the current version of
randomX. Contributions of classes based on other
generators are welcome, and will be included in subsequent
updates to randomX. Each class name is linked to the
javadoc-generated page describing it in more detail.
randomX
generators are derived. A derived class need only implement
nextByte() and whatever mechanisms for seed
specification (if appropriate) it requires.
randomX wrapper for the standard
java.util.Random 48-bit linear congruential generator.
It is provided so that this generator can be easily selected by a
program using randomX. Even though the fundamental
generator is the same, the results from the various methods differ
from those of java.util.Random for a given seed because the
algorithms used by randomX to assemble the various return
types from the low level generator differ from those in the built-in
class (which are not documented).
|
|