|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.math3.random.BitsStreamGenerator org.apache.commons.math3.random.ISAACRandom
public class ISAACRandom
ISAAC: a fast cryptographic pseudo-random number generator
ISAAC (Indirection, Shift, Accumulate, Add, and Count) generates 32-bit
random numbers.
ISAAC has been designed to be cryptographically secure and is inspired
by RC4.
Cycles are guaranteed to be at least 240 values long, and they
are 28295 values long on average.
The results are uniformly distributed, unbiased, and unpredictable unless
you know the seed.
This code is based (with minor changes and improvements) on the original
implementation of the algorithm by Bob Jenkins.
Constructor Summary | |
---|---|
ISAACRandom()
Creates a new ISAAC random number generator. |
|
ISAACRandom(int[] seed)
Creates a new ISAAC random number generator using an int array seed. |
|
ISAACRandom(long seed)
Creates a new ISAAC random number generator using a single long seed. |
Method Summary | |
---|---|
protected int |
next(int bits)
Generate next pseudorandom number. |
void |
setSeed(int seed)
Sets the seed of the underlying random number generator using an int seed. |
void |
setSeed(int[] seed)
Sets the seed of the underlying random number generator using an int array seed. |
void |
setSeed(long seed)
Sets the seed of the underlying random number generator using a long seed. |
Methods inherited from class org.apache.commons.math3.random.BitsStreamGenerator |
---|
clear, 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 ISAACRandom()
public ISAACRandom(long seed)
seed
- Initial seed.public ISAACRandom(int[] seed)
seed
- Initial seed. If null
, the seed will be related
to the current time.Method Detail |
---|
public void setSeed(int seed)
int
seed.
Sequences of values generated starting with the same seeds should be identical.
setSeed
in interface RandomGenerator
setSeed
in class BitsStreamGenerator
seed
- the seed valuepublic void setSeed(long seed)
long
seed.
Sequences of values generated starting with the same seeds should be identical.
setSeed
in interface RandomGenerator
setSeed
in class BitsStreamGenerator
seed
- the seed valuepublic void setSeed(int[] seed)
int
array seed.
Sequences of values generated starting with the same seeds should be identical.
setSeed
in interface RandomGenerator
setSeed
in class BitsStreamGenerator
seed
- the seed valueprotected int next(int bits)
This method is the core generation algorithm. It is used by all the
public generation methods for the various primitive types BitsStreamGenerator.nextBoolean()
, BitsStreamGenerator.nextBytes(byte[])
, BitsStreamGenerator.nextDouble()
,
BitsStreamGenerator.nextFloat()
, BitsStreamGenerator.nextGaussian()
, BitsStreamGenerator.nextInt()
,
BitsStreamGenerator.next(int)
and BitsStreamGenerator.nextLong()
.
next
in class BitsStreamGenerator
bits
- number of random bits to produce
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |