Class KISSRandom
- java.lang.Object
-
- org.apache.commons.rng.core.BaseProvider
-
- org.apache.commons.rng.core.source32.IntProvider
-
- org.apache.commons.rng.core.source32.KISSRandom
-
- All Implemented Interfaces:
RandomIntSource
,RestorableUniformRandomProvider
,UniformRandomProvider
public class KISSRandom extends IntProvider
Port from Marsaglia's "KISS" algorithm. This version contains the correction referred to here in a reply to the original post.- Since:
- 1.0
- See Also:
- KISS (Wikipedia)
-
-
Constructor Summary
Constructors Constructor Description KISSRandom(int[] seed)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]
getStateInternal()
Creates a snapshot of the RNG state.int
next()
protected void
setStateInternal(byte[] s)
Resets the RNG to the givenstate
.-
Methods inherited from class org.apache.commons.rng.core.source32.IntProvider
nextBoolean, nextBytes, nextBytes, nextDouble, nextFloat, nextInt, nextLong, resetCachedState
-
Methods inherited from class org.apache.commons.rng.core.BaseProvider
checkIndex, checkStateSize, composeStateInternal, fillState, fillState, nextInt, nextLong, restoreState, saveState, splitStateInternal, toString
-
-
-
-
Constructor Detail
-
KISSRandom
public KISSRandom(int[] seed)
Creates a new instance.- Parameters:
seed
- Seed. If the length is larger than 4, only the first 4 elements will be used; if smaller, the remaining elements will be automatically set.
-
-
Method Detail
-
getStateInternal
protected byte[] getStateInternal()
Creates a snapshot of the RNG state.- Overrides:
getStateInternal
in classIntProvider
- Returns:
- the internal state.
-
setStateInternal
protected void setStateInternal(byte[] s)
Resets the RNG to the givenstate
.- Overrides:
setStateInternal
in classIntProvider
- Parameters:
s
- State (previously obtained by a call toBaseProvider.getStateInternal()
).- See Also:
BaseProvider.checkStateSize(byte[],int)
-
next
public int next()
- Returns:
- the next random value.
-
-