|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Random net.sourceforge.cilib.math.random.generator.Random net.sourceforge.cilib.math.random.generator.ZiffGFSR4
public class ZiffGFSR4
The GFSR4 generator is like a lagged-fibonacci generator, and produces each number as an `xor''d sum of four previous values.
r_n = r_{n-A} ^^ r_{n-B} ^^ r_{n-C} ^^ r_{n-D}
Ziff notes that "it is now widely known" that two-tap registers have serious flaws, the most obvious one being the three-point correlation that comes from the definition of the generator. Nice mathematical properties can be derived for GFSR's, and numerics bears out the claim that 4-tap GFSR's with appropriately chosen offsets are as random as can be measured, using the author's test.
This implementation uses the values suggested the the example on p392 of Ziff's article: A=471, B=1586, C=6988, D=9689
If the offsets are appropriately chosen (such the one ones in this implementation), then the sequence is said to be maximal. I'm not sure what that means, but I would guess that means all states are part of the same cycle, which would mean that the period for this generator is astronomical; it is (2^K)^D approx 10^{93334} where K=32 is the number of bits in the word, and D is the longest lag. This would also mean that any one random number could easily be zero; ie 0 <= r < 2^32.
Ziff doesn't say so, but it seems to me that the bits are completely independent here, so one could use this as an efficient bit generator; each number supplying 32 random bits. The quality of the generated bits depends on the underlying seeding procedure, which may need to be improved in some circumstances.
- James Theiler
References:
This code is based on the implementation in GSL (GNU Scientific Library) which is also covered by the GNU General Public License. The original C source code is Copyright (C) 1998 James Theiler
Constructor Summary | |
---|---|
ZiffGFSR4()
Create an instance of ZiffGFSR4. |
|
ZiffGFSR4(long seed)
Create an instance with the given seed value. |
Method Summary | |
---|---|
ZiffGFSR4 |
getClone()
Create a cloned copy of the current object and return it. |
protected int |
next(int bits)
|
void |
setSeed(long 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 ZiffGFSR4()
public ZiffGFSR4(long seed)
seed
- The seed value to use.Method Detail |
---|
public ZiffGFSR4 getClone()
getClone
in interface Cloneable
getClone
in class Random
Object.clone()
public void setSeed(long seed)
setSeed
in class Random
protected int next(int bits)
next
in class Random
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |