|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Random
com.buck.commons.algorithms.MersenneTwister
public class MersenneTwister
| Constructor Summary | |
|---|---|
MersenneTwister()
Constructor using the default seed which is generated from system entropy. |
|
MersenneTwister(byte[] bytes)
|
|
MersenneTwister(int[] array)
Constructor using an array of integers as seed. |
|
MersenneTwister(long seed)
Constructor using a given seed. |
|
| Method Summary | |
|---|---|
Object |
clone()
|
protected int |
next(int bits)
Returns an integer with bits bits filled with a random number. |
boolean |
nextBoolean()
This method is missing from jdk 1.0.x and below. |
boolean |
nextBoolean(double probability)
This generates a coin flip with a probability probability of returning true, else returning false. |
boolean |
nextBoolean(float probability)
This generates a coin flip with a probability probability of returning true, else returning false. |
byte |
nextByte()
For completeness' sake, though it's not in java.util.Random. |
void |
nextBytes(byte[] bytes)
A bug fix for all versions of the JDK. |
char |
nextChar()
For completeness' sake, though it's not in java.util.Random. |
double |
nextDouble()
A bug fix for versions of JDK 1.1 and below. |
float |
nextFloat()
A bug fix for versions of JDK 1.1 and below. |
double |
nextGaussian()
A bug fix for all JDK code including 1.2. |
int |
nextInt(int n)
This method is missing from JDK 1.1 and below. |
long |
nextLong(long n)
This method is for completeness' sake. |
short |
nextShort()
For completeness' sake, though it's not in java.util.Random. |
void |
readState(DataInputStream stream)
Reads the entire state of the MersenneTwister RNG from the stream |
void |
setSeed(byte[] manifest)
|
void |
setSeed(int[] array)
Sets the seed of the MersenneTwister using an array of integers. |
void |
setSeed(long seed)
Initalize the pseudo random number generator. |
boolean |
stateEquals(Object o)
|
void |
writeState(DataOutputStream stream)
Writes the entire state of the MersenneTwister RNG to the stream |
| Methods inherited from class java.util.Random |
|---|
nextInt, nextLong |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MersenneTwister()
public MersenneTwister(byte[] bytes)
public MersenneTwister(long seed)
seed - the starting seed for the random number generatorpublic MersenneTwister(int[] array)
array - the array of integers to draw the seed from| Method Detail |
|---|
public Object clone()
throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic boolean stateEquals(Object o)
public void readState(DataInputStream stream)
throws IOException
stream - to read from
IOException - if the read fails
public void writeState(DataOutputStream stream)
throws IOException
stream - the stream to write the RNG state to
IOException - if the write failspublic void setSeed(long seed)
setSeed in class Randompublic void setSeed(byte[] manifest)
public void setSeed(int[] array)
array - the array of seed values to draw fromprotected int next(int bits)
next in class Randompublic boolean nextBoolean()
nextBoolean in class Randompublic boolean nextBoolean(float probability)
probability - the probability that the next call will return true
public boolean nextBoolean(double probability)
probability - the probability that the method returns true
public void nextBytes(byte[] bytes)
nextBytes in class Randompublic byte nextByte()
public char nextChar()
public short nextShort()
public int nextInt(int n)
nextInt in class Randompublic long nextLong(long n)
n - one greater than the maximum value
public float nextFloat()
nextFloat in class Randompublic double nextDouble()
nextDouble in class Randompublic double nextGaussian()
nextGaussian in class Random
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||