public class FourTapRandom
extends java.util.Random
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 and Description |
|---|
FourTapRandom()
Creates a new random number generator.
|
FourTapRandom(long seed)
Creates a new random number generator using a single long seed.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
next(int bits)
Generate next pseudorandom number.
|
void |
setSeed(long seed)
Reinitialize the generator as if just built with the given seed.
|
public FourTapRandom()
The instance is initialized using the current time as the seed.
public FourTapRandom(long seed)
seed - the initial seedpublic void setSeed(long seed)
The state of the generator is exactly the same as a new generator built with the same seed.
setSeed in class java.util.Randomseed - 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.
next in class java.util.Randombits - number of random bits to produceCopyright © 2001-2007 Luc Maisonobe. All Rights Reserved.