|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Random org.knowceans.util.CokusRandom
public class CokusRandom
CokusRandom is a non-static version of the Cokus Mersenne Twister as a Random subclass. (Based on the C code used in LDA-C).
Note: nextUnsignedInt(), next(), and randDouble() are tested for conformity with Cokus, which means they provide sufficient randomness. The other methods should yet be used with caution, esp. if long random sequences are to be generated (Monte Carlo simulation etc.).
TODO: Esp. next(int) needs to be tested against randomness criteria; suspected Markov property seen in nextBoolean(). As point of approach, randDouble() and next() use the original Cokus algorithm and can be used as a reference to test randomness against the nextDouble() and nextInt() method that use the scaling mechanism of Random in connection with Cokus's next(int) as a random number generator.
Field Summary | |
---|---|
static long |
DEFAULTSEED
|
static long |
K
a magic constant |
double |
lastRand
|
static int |
M
a period parameter |
static int |
N
length of state vector |
Constructor Summary | |
---|---|
CokusRandom()
initialise with standard MT seed, 4357. |
|
CokusRandom(long i)
sets the seed (lower half of long taken) |
Method Summary | |
---|---|
static void |
main(java.lang.String[] args)
|
int |
next()
returns the next integer |
boolean |
nextBoolean()
|
void |
nextBytes(byte[] bytes)
|
double |
nextDouble()
|
float |
nextFloat()
|
double |
nextGaussian()
|
int |
nextInt()
|
int |
nextInt(int n)
|
long |
nextLong()
|
long |
nextUnsignedInt()
returns a long in the numerical interval of an unsigned int. |
long |
nextUnsignedLong()
|
double |
randDouble()
returns the next double between 0 and 1. |
int |
reload()
reload the random number buffer |
void |
setSeed(long seed)
Note: only lower half of seed is used. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long DEFAULTSEED
public static int N
public static int M
public static long K
public double lastRand
Constructor Detail |
---|
public CokusRandom()
public CokusRandom(long i)
i
- Method Detail |
---|
public static void main(java.lang.String[] args)
public int next()
public long nextUnsignedInt()
public double randDouble()
public void setSeed(long seed)
setSeed
in class java.util.Random
public int reload()
public double nextDouble()
nextDouble
in class java.util.Random
public boolean nextBoolean()
nextBoolean
in class java.util.Random
public float nextFloat()
nextFloat
in class java.util.Random
public double nextGaussian()
nextGaussian
in class java.util.Random
public int nextInt()
nextInt
in class java.util.Random
public long nextUnsignedLong()
public long nextLong()
nextLong
in class java.util.Random
public void nextBytes(byte[] bytes)
nextBytes
in class java.util.Random
public int nextInt(int n)
nextInt
in class java.util.Random
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |