Class JDKRandomWrapper

  • All Implemented Interfaces:
    org.apache.commons.rng.UniformRandomProvider

    public final class JDKRandomWrapper
    extends Object
    implements org.apache.commons.rng.UniformRandomProvider
    Wraps a Random instance to implement UniformRandomProvider. All methods from the Random that match those in UniformRandomProvider are used directly.

    This class can be used to wrap an instance of SecureRandom. The SecureRandom class provides cryptographic random number generation. The features available depend on the Java version and platform. Consult the Java documentation for more details.

    Note: Use of java.util.Random is not recommended for applications. There are many other pseudo-random number generators that are statistically superior and often faster (see RandomSource).

    Since:
    1.3
    See Also:
    SecureRandom, RandomSource
    • Constructor Detail

      • JDKRandomWrapper

        public JDKRandomWrapper​(Random rng)
        Create a wrapper around a Random instance.
        Parameters:
        rng - JDK Random instance to which the random number generation is delegated.
    • Method Detail

      • nextBytes

        public void nextBytes​(byte[] bytes)
        Specified by:
        nextBytes in interface org.apache.commons.rng.UniformRandomProvider
      • nextBytes

        public void nextBytes​(byte[] bytes,
                              int start,
                              int len)
        Specified by:
        nextBytes in interface org.apache.commons.rng.UniformRandomProvider
      • nextInt

        public int nextInt()
        Specified by:
        nextInt in interface org.apache.commons.rng.UniformRandomProvider
      • nextInt

        public int nextInt​(int n)
        Specified by:
        nextInt in interface org.apache.commons.rng.UniformRandomProvider
      • nextLong

        public long nextLong()
        Specified by:
        nextLong in interface org.apache.commons.rng.UniformRandomProvider
      • nextLong

        public long nextLong​(long n)
        Specified by:
        nextLong in interface org.apache.commons.rng.UniformRandomProvider
      • nextBoolean

        public boolean nextBoolean()
        Specified by:
        nextBoolean in interface org.apache.commons.rng.UniformRandomProvider
      • nextFloat

        public float nextFloat()
        Specified by:
        nextFloat in interface org.apache.commons.rng.UniformRandomProvider
      • nextDouble

        public double nextDouble()
        Specified by:
        nextDouble in interface org.apache.commons.rng.UniformRandomProvider