Interface UniformRandomProvider

All Known Subinterfaces:
JumpableUniformRandomProvider, LongJumpableUniformRandomProvider, RestorableUniformRandomProvider, SplittableUniformRandomProvider
All Known Implementing Classes:
AbstractL128, AbstractL64, AbstractL64X128, AbstractPcg6432, AbstractPcgMcg6432, AbstractWell, AbstractXoRoShiRo1024, AbstractXoRoShiRo128, AbstractXoRoShiRo64, AbstractXoShiRo128, AbstractXoShiRo256, AbstractXoShiRo512, BaseProvider, DotyHumphreySmallFastCounting32, DotyHumphreySmallFastCounting64, IntProvider, ISAACRandom, JDKRandom, JDKRandomWrapper, JenkinsSmallFast32, JenkinsSmallFast64, KISSRandom, L128X1024Mix, L128X128Mix, L128X256Mix, L32X64Mix, L64X1024Mix, L64X128Mix, L64X128StarStar, L64X256Mix, LongProvider, MersenneTwister, MersenneTwister64, MiddleSquareWeylSequence, MultiplyWithCarry256, PcgMcgXshRr32, PcgMcgXshRs32, PcgRxsMXs64, PcgXshRr32, PcgXshRs32, SplitMix64, TwoCmres, Well1024a, Well19937a, Well19937c, Well44497a, Well44497b, Well512a, XoRoShiRo1024PlusPlus, XoRoShiRo1024Star, XoRoShiRo1024StarStar, XoRoShiRo128Plus, XoRoShiRo128PlusPlus, XoRoShiRo128StarStar, XoRoShiRo64Star, XoRoShiRo64StarStar, XorShift1024Star, XorShift1024StarPhi, XoShiRo128Plus, XoShiRo128PlusPlus, XoShiRo128StarStar, XoShiRo256Plus, XoShiRo256PlusPlus, XoShiRo256StarStar, XoShiRo512Plus, XoShiRo512PlusPlus, XoShiRo512StarStar

public interface UniformRandomProvider
Applies to generators of random number sequences that follow a uniform distribution.
Since:
1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    default DoubleStream
    Returns an effectively unlimited stream of double values between 0 (inclusive) and 1 (exclusive).
    default DoubleStream
    doubles(double origin, double bound)
    Returns an effectively unlimited stream of double values between the specified origin (inclusive) and the specified bound (exclusive).
    default DoubleStream
    doubles(long streamSize)
    Returns a stream producing the given streamSize number of double values between 0 (inclusive) and 1 (exclusive).
    default DoubleStream
    doubles(long streamSize, double origin, double bound)
    Returns a stream producing the given streamSize number of double values between the specified origin (inclusive) and the specified bound (exclusive).
    default IntStream
    Returns an effectively unlimited stream of int values.
    default IntStream
    ints(int origin, int bound)
    Returns an effectively unlimited stream of int values between the specified origin (inclusive) and the specified bound (exclusive).
    default IntStream
    ints(long streamSize)
    Returns a stream producing the given streamSize number of int values.
    default IntStream
    ints(long streamSize, int origin, int bound)
    Returns a stream producing the given streamSize number of int values between the specified origin (inclusive) and the specified bound (exclusive).
    default LongStream
    Returns an effectively unlimited stream of long values.
    default LongStream
    longs(long streamSize)
    Returns a stream producing the given streamSize number of long values.
    default LongStream
    longs(long origin, long bound)
    Returns an effectively unlimited stream of long values between the specified origin (inclusive) and the specified bound (exclusive).
    default LongStream
    longs(long streamSize, long origin, long bound)
    Returns a stream producing the given streamSize number of long values between the specified origin (inclusive) and the specified bound (exclusive).
    default boolean
    Generates a boolean value.
    default void
    nextBytes(byte[] bytes)
    Generates byte values and places them into a user-supplied array.
    default void
    nextBytes(byte[] bytes, int start, int len)
    Generates byte values and places them into a user-supplied array.
    default double
    Generates a double value between 0 (inclusive) and 1 (exclusive).
    default double
    nextDouble(double bound)
    Generates a double value between 0 (inclusive) and the specified bound (exclusive).
    default double
    nextDouble(double origin, double bound)
    Generates a double value between the specified origin (inclusive) and the specified bound (exclusive).
    default float
    Generates a float value between 0 (inclusive) and 1 (exclusive).
    default float
    nextFloat(float bound)
    Generates a float value between 0 (inclusive) and the specified bound (exclusive).
    default float
    nextFloat(float origin, float bound)
    Generates a float value between the specified origin (inclusive) and the specified bound (exclusive).
    default int
    Generates an int value.
    default int
    nextInt(int n)
    Generates an int value between 0 (inclusive) and the specified value (exclusive).
    default int
    nextInt(int origin, int bound)
    Generates an int value between the specified origin (inclusive) and the specified bound (exclusive).
    long
    Generates a long value.
    default long
    nextLong(long n)
    Generates a long value between 0 (inclusive) and the specified value (exclusive).
    default long
    nextLong(long origin, long bound)
    Generates a long value between the specified origin (inclusive) and the specified bound (exclusive).
  • Method Details

    • nextBytes

      default void nextBytes(byte[] bytes)
      Generates byte values and places them into a user-supplied array.

      The number of random bytes produced is equal to the length of the byte array.

      Parameters:
      bytes - Byte array in which to put the random bytes. Cannot be null.
    • nextBytes

      default void nextBytes(byte[] bytes, int start, int len)
      Generates byte values and places them into a user-supplied array.

      The array is filled with bytes extracted from random integers. This implies that the number of random bytes generated may be larger than the length of the byte array.

      Parameters:
      bytes - Array in which to put the generated bytes. Cannot be null.
      start - Index at which to start inserting the generated bytes.
      len - Number of bytes to insert.
      Throws:
      IndexOutOfBoundsException - if start < 0 or start >= bytes.length.
      IndexOutOfBoundsException - if len < 0 or len > bytes.length - start.
    • nextInt

      default int nextInt()
      Generates an int value.
      Returns:
      the next random value.
    • nextInt

      default int nextInt(int n)
      Generates an int value between 0 (inclusive) and the specified value (exclusive).
      Parameters:
      n - Bound on the random number to be returned. Must be positive.
      Returns:
      a random int value between 0 (inclusive) and n (exclusive).
      Throws:
      IllegalArgumentException - if n is not above zero.
    • nextInt

      default int nextInt(int origin, int bound)
      Generates an int value between the specified origin (inclusive) and the specified bound (exclusive).
      Parameters:
      origin - Lower bound on the random number to be returned.
      bound - Upper bound (exclusive) on the random number to be returned.
      Returns:
      a random int value between origin (inclusive) and bound (exclusive).
      Throws:
      IllegalArgumentException - if origin is greater than or equal to bound.
      Since:
      1.5
    • nextLong

      long nextLong()
      Generates a long value.
      Returns:
      the next random value.
    • nextLong

      default long nextLong(long n)
      Generates a long value between 0 (inclusive) and the specified value (exclusive).
      Parameters:
      n - Bound on the random number to be returned. Must be positive.
      Returns:
      a random long value between 0 (inclusive) and n (exclusive).
      Throws:
      IllegalArgumentException - if n is not greater than 0.
    • nextLong

      default long nextLong(long origin, long bound)
      Generates a long value between the specified origin (inclusive) and the specified bound (exclusive).
      Parameters:
      origin - Lower bound on the random number to be returned.
      bound - Upper bound (exclusive) on the random number to be returned.
      Returns:
      a random long value between origin (inclusive) and bound (exclusive).
      Throws:
      IllegalArgumentException - if origin is greater than or equal to bound.
      Since:
      1.5
    • nextBoolean

      default boolean nextBoolean()
      Generates a boolean value.
      Returns:
      the next random value.
    • nextFloat

      default float nextFloat()
      Generates a float value between 0 (inclusive) and 1 (exclusive).
      Returns:
      the next random value between 0 (inclusive) and 1 (exclusive).
    • nextFloat

      default float nextFloat(float bound)
      Generates a float value between 0 (inclusive) and the specified bound (exclusive).
      Parameters:
      bound - Upper bound (exclusive) on the random number to be returned.
      Returns:
      a random float value between 0 (inclusive) and bound (exclusive).
      Throws:
      IllegalArgumentException - if bound is not both finite and greater than 0.
      Since:
      1.5
    • nextFloat

      default float nextFloat(float origin, float bound)
      Generates a float value between the specified origin (inclusive) and the specified bound (exclusive).
      Parameters:
      origin - Lower bound on the random number to be returned.
      bound - Upper bound (exclusive) on the random number to be returned.
      Returns:
      a random float value between origin (inclusive) and bound (exclusive).
      Throws:
      IllegalArgumentException - if origin is not finite, or bound is not finite, or origin is greater than or equal to bound.
      Since:
      1.5
    • nextDouble

      default double nextDouble()
      Generates a double value between 0 (inclusive) and 1 (exclusive).
      Returns:
      the next random value between 0 (inclusive) and 1 (exclusive).
    • nextDouble

      default double nextDouble(double bound)
      Generates a double value between 0 (inclusive) and the specified bound (exclusive).
      Parameters:
      bound - Upper bound (exclusive) on the random number to be returned.
      Returns:
      a random double value between 0 (inclusive) and bound (exclusive).
      Throws:
      IllegalArgumentException - if bound is not both finite and greater than 0.
      Since:
      1.5
    • nextDouble

      default double nextDouble(double origin, double bound)
      Generates a double value between the specified origin (inclusive) and the specified bound (exclusive).
      Parameters:
      origin - Lower bound on the random number to be returned.
      bound - Upper bound (exclusive) on the random number to be returned.
      Returns:
      a random double value between origin (inclusive) and bound (exclusive).
      Throws:
      IllegalArgumentException - if origin is not finite, or bound is not finite, or origin is greater than or equal to bound.
      Since:
      1.5
    • ints

      default IntStream ints()
      Returns an effectively unlimited stream of int values.
      Returns:
      a stream of random int values.
      Since:
      1.5
    • ints

      default IntStream ints(int origin, int bound)
      Returns an effectively unlimited stream of int values between the specified origin (inclusive) and the specified bound (exclusive).
      Parameters:
      origin - Lower bound on the random number to be returned.
      bound - Upper bound (exclusive) on the random number to be returned.
      Returns:
      a stream of random values between the specified origin (inclusive) and the specified bound (exclusive).
      Throws:
      IllegalArgumentException - if origin is greater than or equal to bound.
      Since:
      1.5
    • ints

      default IntStream ints(long streamSize)
      Returns a stream producing the given streamSize number of int values.
      Parameters:
      streamSize - Number of values to generate.
      Returns:
      a stream of random int values; the stream is limited to the given streamSize.
      Throws:
      IllegalArgumentException - if streamSize is negative.
      Since:
      1.5
    • ints

      default IntStream ints(long streamSize, int origin, int bound)
      Returns a stream producing the given streamSize number of int values between the specified origin (inclusive) and the specified bound (exclusive).
      Parameters:
      streamSize - Number of values to generate.
      origin - Lower bound on the random number to be returned.
      bound - Upper bound (exclusive) on the random number to be returned.
      Returns:
      a stream of random values between the specified origin (inclusive) and the specified bound (exclusive); the stream is limited to the given streamSize.
      Throws:
      IllegalArgumentException - if streamSize is negative, or if origin is greater than or equal to bound.
      Since:
      1.5
    • longs

      default LongStream longs()
      Returns an effectively unlimited stream of long values.
      Returns:
      a stream of random long values.
      Since:
      1.5
    • longs

      default LongStream longs(long origin, long bound)
      Returns an effectively unlimited stream of long values between the specified origin (inclusive) and the specified bound (exclusive).
      Parameters:
      origin - Lower bound on the random number to be returned.
      bound - Upper bound (exclusive) on the random number to be returned.
      Returns:
      a stream of random values between the specified origin (inclusive) and the specified bound (exclusive).
      Throws:
      IllegalArgumentException - if origin is greater than or equal to bound.
      Since:
      1.5
    • longs

      default LongStream longs(long streamSize)
      Returns a stream producing the given streamSize number of long values.
      Parameters:
      streamSize - Number of values to generate.
      Returns:
      a stream of random long values; the stream is limited to the given streamSize.
      Throws:
      IllegalArgumentException - if streamSize is negative.
      Since:
      1.5
    • longs

      default LongStream longs(long streamSize, long origin, long bound)
      Returns a stream producing the given streamSize number of long values between the specified origin (inclusive) and the specified bound (exclusive).
      Parameters:
      streamSize - Number of values to generate.
      origin - Lower bound on the random number to be returned.
      bound - Upper bound (exclusive) on the random number to be returned.
      Returns:
      a stream of random values between the specified origin (inclusive) and the specified bound (exclusive); the stream is limited to the given streamSize.
      Throws:
      IllegalArgumentException - if streamSize is negative, or if origin is greater than or equal to bound.
      Since:
      1.5
    • doubles

      default DoubleStream doubles()
      Returns an effectively unlimited stream of double values between 0 (inclusive) and 1 (exclusive).
      Returns:
      a stream of random values between 0 (inclusive) and 1 (exclusive).
      Since:
      1.5
    • doubles

      default DoubleStream doubles(double origin, double bound)
      Returns an effectively unlimited stream of double values between the specified origin (inclusive) and the specified bound (exclusive).
      Parameters:
      origin - Lower bound on the random number to be returned.
      bound - Upper bound (exclusive) on the random number to be returned.
      Returns:
      a stream of random values between the specified origin (inclusive) and the specified bound (exclusive).
      Throws:
      IllegalArgumentException - if origin is not finite, or bound is not finite, or origin is greater than or equal to bound.
      Since:
      1.5
    • doubles

      default DoubleStream doubles(long streamSize)
      Returns a stream producing the given streamSize number of double values between 0 (inclusive) and 1 (exclusive).
      Parameters:
      streamSize - Number of values to generate.
      Returns:
      a stream of random values between 0 (inclusive) and 1 (exclusive); the stream is limited to the given streamSize.
      Throws:
      IllegalArgumentException - if streamSize is negative.
      Since:
      1.5
    • doubles

      default DoubleStream doubles(long streamSize, double origin, double bound)
      Returns a stream producing the given streamSize number of double values between the specified origin (inclusive) and the specified bound (exclusive).
      Parameters:
      streamSize - Number of values to generate.
      origin - Lower bound on the random number to be returned.
      bound - Upper bound (exclusive) on the random number to be returned.
      Returns:
      a stream of random values between the specified origin (inclusive) and the specified bound (exclusive); the stream is limited to the given streamSize.
      Throws:
      IllegalArgumentException - if streamSize is negative, or if origin is not finite, or bound is not finite, or origin is greater than or equal to bound.
      Since:
      1.5