

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
Object com.internationalnetwork.math.random.XORShift
public class XORShift
The XORShift
class is a consistent alternative to Java's
builtin java.util.Random class. Although it doesn't offer all the
same methods, the key methods are provide simple and reliable longsequence
pseudorandom number generation. Steps have been taken in this
algorithm to minimize processor overhead, and to ensure the sequence is not
repeated for as long as possible (all pseudorandom number generators
suffer from the same problem in that the generated sequences eventually
repeat).
The algorithm itself uses a series of three eXclusive OR instructions combined with bitwise Shift operations, all acting on the current seed which doubles as the random number. Unlike more complicated math operations, which are typically utilized by other pseudorandom number generators, these operations are very fast because they consume fewer CPU cycles (this may be important to game developers, or other developers who are developing other timesensitive applications).
This algorithm will never generate zeros (unless the seed is set to 0, in which case every number will always be zero). This is the infamous shortcoming of this algorithm.
Field Summary  

static String 
VERSION
Version number of this Package (readonly). 
Constructor Summary  

XORShift(long seed)
Instantiate a new XORShift object with the specified seed. The resulting pseudorandom number sequence is of "medium quality" which is an improvement over the default java.util.Random class. 
Method Summary  

long 
currentLong()
Calculate and return the current pseudorandom number. 
int 
nextInt()
Return the next pseudorandom number. 
long 
nextLong()
Calculate and return the next pseudorandom number. 
Methods inherited from class Object 

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Field Detail 

public static final String VERSION
Constructor Detail 

public XORShift(long seed)
IMPORTANT: If your seed is zero, then every result will also be zero, which renders the numeric sequence as trivially predictable. This is the infamous shortcoming of this algorithm.
seed
 Seed that the random number generator is initialized with.Method Detail 

public long currentLong()
public int nextInt()
public long nextLong()


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 