Class PcgMcgXshRs32

All Implemented Interfaces:
RandomIntSource, RestorableUniformRandomProvider, UniformRandomProvider

public class PcgMcgXshRs32 extends IntProvider
A Permuted Congruential Generator (PCG) that is composed of a 64-bit Multiplicative Congruential Generator (MCG) combined with the XSH-RS (xorshift; random shift) output transformation to create 32-bit output.

State size is 64 bits and the period is 262.

Since:
1.3
See Also:
  • Constructor Details

    • PcgMcgXshRs32

      public PcgMcgXshRs32(Long seed)
      Creates a new instance.
      Parameters:
      seed - Initial seed.
  • Method Details

    • transform

      protected int transform(long x)
      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:
      getStateInternal in class IntProvider
      Returns:
      the internal state.
    • setStateInternal

      protected void setStateInternal(byte[] s)
      Resets the RNG to the given state.
      Overrides:
      setStateInternal in class IntProvider
      Parameters:
      s - State (previously obtained by a call to BaseProvider.getStateInternal()).
      See Also: