net.sourceforge.cilib.math.random.generator
Class ZiffGFSR4

java.lang.Object
  extended by java.util.Random
      extended by net.sourceforge.cilib.math.random.generator.Random
          extended by net.sourceforge.cilib.math.random.generator.ZiffGFSR4
All Implemented Interfaces:
Serializable, Cloneable

public class ZiffGFSR4
extends Random

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

Author:
Edwin Peer
See Also:
Serialized Form

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

ZiffGFSR4

public ZiffGFSR4()
Create an instance of ZiffGFSR4.


ZiffGFSR4

public ZiffGFSR4(long seed)
Create an instance with the given seed value.

Parameters:
seed - The seed value to use.
Method Detail

getClone

public ZiffGFSR4 getClone()
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Specified by:
getClone in interface Cloneable
Specified by:
getClone in class Random
Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

setSeed

public void setSeed(long seed)

Overrides:
setSeed in class Random

next

protected int next(int bits)

Overrides:
next in class Random


Copyright © 2009 CIRG. All Rights Reserved.