|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Random
org.spaceroots.mantissa.random.FourTapRandom
This class implements a powerful pseudo-random number generator studied by Robert M Ziff.
This generator belongs to the family of Generalized Feedback Shift-Register (GFSR) generators, but uses four feedback taps instead of two, thus greatly improving their quality for Monte-Carlo simulations.
This generator is described in a paper by Robert M. Ziff in
1997: Four-tap
shift-register-sequence random-number generators, it is
generator 9f (defined as R(471, 1586, 6988, 9689)) of
the paper. It has been kindly contributed to mantissa by Bill
Maier.
The class is implemented as a specialization of the standard
java.util.Random class. This allows to use it in
algorithms expecting a standard random generator, and hence benefit
from a better generator without code change.
| Constructor Summary | |
FourTapRandom()
Creates a new random number generator. |
|
FourTapRandom(long seed)
Creates a new random number generator using a single long seed. |
|
| Method Summary | |
protected int |
next(int bits)
Generate next pseudorandom number. |
void |
setSeed(long seed)
Reinitialize the generator as if just built with the given seed. |
| Methods inherited from class java.util.Random |
nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public FourTapRandom()
The instance is initialized using the current time as the seed.
public FourTapRandom(long seed)
seed - the initial seed| Method Detail |
public void setSeed(long seed)
The state of the generator is exactly the same as a new generator built with the same seed.
seed - the initial seedprotected int next(int bits)
This method is the core generation algorithm. As per
Random contract, it is used by all the
public generation methods for the various primitive types nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt and nextLong.
bits - number of random bits to produce
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||