Class PcgMcgXshRr32
java.lang.Object
org.apache.commons.rng.core.BaseProvider
org.apache.commons.rng.core.source32.IntProvider
org.apache.commons.rng.core.source32.PcgMcgXshRr32
- All Implemented Interfaces:
RandomIntSource, RestorableUniformRandomProvider, UniformRandomProvider
A Permuted Congruential Generator (PCG) that is composed of a 64-bit Multiplicative Congruential
Generator (MCG) combined with the XSH-RR (xorshift; random rotate) output
transformation to create 32-bit output.
State size is 64 bits and the period is 262.
- Since:
- 1.3
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]Creates a snapshot of the RNG state.intnext()Return the next random value.protected voidsetStateInternal(byte[] s) Resets the RNG to the givenstate.protected inttransform(long x) Transform the 64-bit state of the generator to a 32-bit output.Methods inherited from class IntProvider
nextBoolean, nextBytes, nextBytes, nextDouble, nextInt, nextLong, resetCachedStateMethods inherited from class BaseProvider
checkIndex, checkStateSize, composeStateInternal, extendSeed, extendSeed, fillState, fillState, restoreState, saveState, splitStateInternal, toString
-
Constructor Details
-
PcgMcgXshRr32
-
-
Method Details
-
transform
Transform the 64-bit state of the generator to a 32-bit output. The transformation function shall vary with respect to different generators.- Parameters:
x- State.- Returns:
- the output
-
next
public int next()Return the next random value.- Returns:
- the next random value.
-
getStateInternal
protected byte[] getStateInternal()Creates a snapshot of the RNG state.- Overrides:
getStateInternalin classIntProvider- Returns:
- the internal state.
-
setStateInternal
protected void setStateInternal(byte[] s) Resets the RNG to the givenstate.- Overrides:
setStateInternalin classIntProvider- Parameters:
s- State (previously obtained by a call toBaseProvider.getStateInternal()).- See Also:
-