Module java.base
Package java.util.random

Interface RandomGenerator

All Known Subinterfaces:
RandomGenerator.ArbitrarilyJumpableGenerator, RandomGenerator.JumpableGenerator, RandomGenerator.LeapableGenerator, RandomGenerator.SplittableGenerator, RandomGenerator.StreamableGenerator
All Known Implementing Classes:
Random, RandomSupport.AbstractArbitrarilyJumpableGenerator, RandomSupport.AbstractSpliteratorGenerator, RandomSupport.AbstractSplittableGenerator, RandomSupport.AbstractSplittableWithBrineGenerator, SecureRandom, SplittableRandom, ThreadLocalRandom

                                                        public interface RandomGenerator
                        
                        
The RandomGenerator interface is designed to provide a common protocol for objects that generate random or (more typically) pseudorandom sequences of numbers (or Boolean values). Such a sequence may be obtained by either repeatedly invoking a method that returns a single (pseudo)randomly chosen value, or by invoking a method that returns a stream of (pseudo)randomly chosen values.

Ideally, given an implicitly or explicitly specified range of values, each value would be chosen independently and uniformly from that range. In practice, one may have to settle for some approximation to independence and uniformity.

In the case of int, long, and boolean values, if there is no explicit specification of range, then the range includes all possible values of the type. In the case of float and double values, first a value is always chosen uniformly from the set of 2w values between 0.0 (inclusive) and 1.0 (exclusive), where w is 23 for float values and 52 for double values, such that adjacent values differ by 2w (notice that this set is a subset of the set of all representable floating-point values between 0.0 (inclusive) and 1.0 (exclusive)); then if an explicit range was specified, then the chosen number is computationally scaled and translated so as to appear to have been chosen approximately uniformly from that explicit range.

Each method that returns a stream produces a stream of values each of which is chosen in the same manner as for a method that returns a single (pseudo)randomly chosen value. For example, if r implements RandomGenerator, then the method call r.ints(100) returns a stream of 100 int values. These are not necessarily the exact same values that would have been returned if instead r.nextInt() had been called 100 times; all that is guaranteed is that each value in the stream is chosen in a similar (pseudo)random manner from the same range.

Every object that implements the RandomGenerator interface by using a pseudorandom algorithm is assumed to contain a finite amount of state. Using such an object to generate a pseudorandomly chosen value alters its state by computing a new state as a function of the current state, without reference to any information other than the current state. The number of distinct possible states of such an object is called its period. (Some implementations of the RandomGenerator interface may be truly random rather than pseudorandom, for example relying on the statistical behavior of a physical object to derive chosen values. Such implementations do not have a fixed period.)

As a rule, objects that implement the RandomGenerator interface need not be thread-safe. It is recommended that multithreaded applications use either ThreadLocalRandom or (preferably) pseudorandom number generators that implement the RandomGenerator.SplittableGenerator or RandomGenerator.JumpableGenerator interface.

To implement this interface, a class only needs to provide concrete definitions for the methods and nextLong () Default implementations are provided for all other methods (but it may be desirable to override some of them, especially nextInt() if the underlying algorithm is int-based). Moreover, it may be preferable instead to implement a more specialized interface such as RandomGenerator.JumpableGenerator or RandomGenerator.LeapableGenerator, or to extend an abstract implementation-support class such as RandomSupport.AbstractSplittableGenerator or RandomSupport.AbstractArbitrarilyJumpableGenerator.

Objects that implement RandomGenerator are typically not cryptographically secure. Consider instead using SecureRandom to get a cryptographically secure pseudorandom number generator for use by security-sensitive applications. Note, however, that SecureRandom does implement the RandomGenerator interface, so that instances of SecureRandom may be used interchangeably with other types of pseudorandom generators in applications that do not require a secure generator.

Since:
16
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    This interface is designed to provide a common protocol for objects that generate sequences of pseudorandom numbers (or Boolean values) and furthermore can easily jump to an arbitrarily specified distant point in the state cycle.
    static interface 
    This interface is designed to provide a common protocol for objects that generate pseudorandom sequences of numbers (or Boolean values) and furthermore can easily jump forward (by a fixed amount) to a distant point in the state cycle.
    static interface 
    This interface is designed to provide a common protocol for objects that generate sequences of pseudorandom numbers (or Boolean values) and furthermore can easily not only jump but also leap to a very distant point in the state cycle.
    static class 
    Properties of RandomGenerators.
    static interface 
    This interface is designed to provide a common protocol for objects that generate sequences of pseudorandom numbers (or Boolean values) and furthermore can be split into two objects (the original one and a new one) each of which obey that same protocol (and therefore can be recursively split indefinitely).
    static interface 
    The RandomGenerator.StreamableGenerator interface augments the RandomGenerator interface to provide methods that return streams of RandomGenerator objects.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static BigInteger
    The (negative) value that may be returned by the period() if this generator has a huge period (larger than 2**(2**16)).
    static BigInteger
    The (negative) value returned by the period() if this generator has no period because it is truly random rather than just pseudorandom.
    static BigInteger
    The property returned by period() if the period is unknown.
  • Method Summary

    Modifier and Type
    Method
    Description
    all()
    Returns a stream of all available RandomGeneratorFactory(s).
    default DoubleStream
    Returns an effectively unlimited stream of (pseudo)randomly chosen double values.
    default DoubleStream
    doubles​(double randomNumberOrigin, double randomNumberBound)
    Returns an effectively unlimited stream of (pseudo)randomly chosen double values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).
    default DoubleStream
    doubles​(long streamSize)
    Returns a stream producing the given streamSize number of (pseudo)randomly chosen double values.
    default DoubleStream
    doubles​(long streamSize, double randomNumberOrigin, double randomNumberBound)
    Returns a stream producing the given streamSize number of (pseudo)randomly chosen double values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).
    factoryOf​(String name)
    Returns a RandomGeneratorFactory that can produce instances of RandomGenerator that utilize the name algorithm.
    default IntStream
    ints()
    Returns an effectively unlimited stream of (pseudo)randomly chosen int values.
    default IntStream
    ints​(int randomNumberOrigin, int randomNumberBound)
    Returns an effectively unlimited stream of (pseudo)randomly chosen int values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).
    default IntStream
    ints​(long streamSize)
    Returns a stream producing the given streamSize number of (pseudo)randomly chosen int values.
    default IntStream
    ints​(long streamSize, int randomNumberOrigin, int randomNumberBound)
    Returns a stream producing the given streamSize number of (pseudo)randomly chosen int values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).
    default LongStream
    longs()
    Returns an effectively unlimited stream of (pseudo)randomly chosen long values.
    default LongStream
    longs​(long streamSize)
    Returns a stream producing the given streamSize number of (pseudo)randomly chosen long values.
    default LongStream
    longs​(long randomNumberOrigin, long randomNumberBound)
    Returns an effectively unlimited stream of (pseudo)randomly chosen long values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).
    default LongStream
    longs​(long streamSize, long randomNumberOrigin, long randomNumberBound)
    Returns a stream producing the given streamSize number of (pseudo)randomly chosen long values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).
    default boolean
    Returns a (pseudo)randomly chosen boolean value.
    default void
    nextBytes​(byte[] bytes)
    Fills a user-supplied byte array with generated byte values (pseudo)randomly chosen uniformly from the range of values between -128 (inclusive) and 255 (inclusive).
    default double
    Returns a pseudorandom double value between zero (inclusive) and one (exclusive).
    default double
    nextDouble​(double bound)
    Returns a (pseudo)randomly chosen double value between zero (inclusive) and the specified bound (exclusive).
    default double
    nextDouble​(double origin, double bound)
    Returns a (pseudo)randomly chosen double value between the specified origin (inclusive) and the specified bound (exclusive).
    default double
    Returns a nonnegative double value (pseudo)randomly chosen from an exponential distribution whose mean is 1.
    default float
    Returns a pseudorandom float value between zero (inclusive) and one (exclusive).
    default float
    nextFloat​(float bound)
    Returns a (pseudo)randomly chosen float value between zero (inclusive) and the specified bound (exclusive).
    default float
    nextFloat​(float origin, float bound)
    Returns a (pseudo)randomly chosen float value between the specified origin (inclusive) and the specified bound (exclusive).
    default double
    Returns a double value (pseudo)randomly chosen from a Gaussian (normal) distribution whose mean is 0 and whose standard deviation is 1.
    default double
    nextGaussian​(double mean, double stddev)
    Returns a double value (pseudo)randomly chosen from a Gaussian (normal) distribution with a mean and standard deviation specified by the arguments.
    default int
    Returns a (pseudo)randomly chosen int value.
    default int
    nextInt​(int bound)
    Returns a (pseudo)randomly chosen int value between zero (inclusive) and the specified bound (exclusive).
    default int
    nextInt​(int origin, int bound)
    Returns a (pseudo)randomly chosen int value between the specified origin (inclusive) and the specified bound (exclusive).
    long
    Returns a (pseudo)randomly chosen long value.
    default long
    nextLong​(long bound)
    Returns a (pseudo)randomly chosen long value between zero (inclusive) and the specified bound (exclusive).
    default long
    nextLong​(long origin, long bound)
    Returns a (pseudo)randomly chosen long value between the specified origin (inclusive) and the specified bound (exclusive).
    of​(String name)
    Returns an instance of RandomGenerator that utilizes the name algorithm.
  • Field Details

    • UNKNOWN_PERIOD

      static final  BigInteger UNKNOWN_PERIOD
      The property returned by period() if the period is unknown.

    • TRULY_RANDOM

      static final  BigInteger TRULY_RANDOM
      The (negative) value returned by the period() if this generator has no period because it is truly random rather than just pseudorandom.

    • HUGE_PERIOD

      static final  BigInteger HUGE_PERIOD
      The (negative) value that may be returned by the period() if this generator has a huge period (larger than 2**(2**16)).

  • Method Details

    • of

      static RandomGenerator of(String name)
      Returns an instance of RandomGenerator that utilizes the name algorithm.
      Parameters:
      name - Name of random number generator algorithm
      Returns:
      An instance of RandomGenerator

    • factoryOf

      static RandomGeneratorFactory<RandomGenerator> factoryOf(String name)
      Returns a RandomGeneratorFactory that can produce instances of RandomGenerator that utilize the name algorithm.
      Parameters:
      name - Name of random number generator algorithm
      Returns:
      RandomGeneratorFactory of RandomGenerator

    • all

      Returns a stream of all available RandomGeneratorFactory(s).
      Returns:
      Stream of all available RandomGeneratorFactory(s).

    • doubles

      default DoubleStream doubles()
      Returns an effectively unlimited stream of (pseudo)randomly chosen double values.
      Implementation Note:
      It is permitted to implement this method in a manner equivalent to doubles (Long.MAX_VALUE). The default implementation produces a sequential stream that repeatedly calls nextDouble().
      Returns:
      a stream of (pseudo)randomly chosen double values

    • doubles

      default DoubleStream doubles(double randomNumberOrigin, double randomNumberBound)
      Returns an effectively unlimited stream of (pseudo)randomly chosen double values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).
      Implementation Note:
      It is permitted to implement this method in a manner equivalent to doubles (Long.MAX_VALUE, randomNumberOrigin, randomNumberBound). The default implementation produces a sequential stream that repeatedly calls nextDouble(randomNumberOrigin, randomNumberBound).
      Parameters:
      randomNumberOrigin - the least value that can be produced
      randomNumberBound - the upper bound (exclusive) for each value produced
      Returns:
      a stream of (pseudo)randomly chosen double values, each between the specified origin (inclusive) and the specified bound (exclusive)
      Throws:
      IllegalArgumentException - if randomNumberOrigin is not finite, or randomNumberBound is not finite, or randomNumberOrigin is greater than or equal to randomNumberBound

    • doubles

      default DoubleStream doubles(long streamSize)
      Returns a stream producing the given streamSize number of (pseudo)randomly chosen double values.
      Implementation Note:
      The default implementation produces a sequential stream that repeatedly calls nextDouble().
      Parameters:
      streamSize - the number of values to generate
      Returns:
      a stream of (pseudo)randomly chosen double values
      Throws:
      IllegalArgumentException - if streamSize is less than zero

    • doubles

      default DoubleStream doubles(long streamSize, double randomNumberOrigin, double randomNumberBound)
      Returns a stream producing the given streamSize number of (pseudo)randomly chosen double values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).
      Implementation Note:
      The default implementation produces a sequential stream that repeatedly calls nextDouble(randomNumberOrigin, randomNumberBound).
      Parameters:
      streamSize - the number of values to generate
      randomNumberOrigin - the least value that can be produced
      randomNumberBound - the upper bound (exclusive) for each value produced
      Returns:
      a stream of (pseudo)randomly chosen double values, each between the specified origin (inclusive) and the specified bound (exclusive)
      Throws:
      IllegalArgumentException - if streamSize is less than zero, or randomNumberOrigin is not finite, or randomNumberBound is not finite, or randomNumberOrigin is greater than or equal to randomNumberBound

    • ints

      default IntStream ints()
      Returns an effectively unlimited stream of (pseudo)randomly chosen int values.
      Implementation Note:
      It is permitted to implement this method in a manner equivalent to ints (Long.MAX_VALUE). The default implementation produces a sequential stream that repeatedly calls nextInt().
      Returns:
      a stream of (pseudo)randomly chosen int values

    • ints

      default IntStream ints(int randomNumberOrigin, int randomNumberBound)
      Returns an effectively unlimited stream of (pseudo)randomly chosen int values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).
      Implementation Note:
      It is permitted to implement this method in a manner equivalent to ints (Long.MAX_VALUE, randomNumberOrigin, randomNumberBound). The default implementation produces a sequential stream that repeatedly calls nextInt(randomNumberOrigin, randomNumberBound).
      Parameters:
      randomNumberOrigin - the least value that can be produced
      randomNumberBound - the upper bound (exclusive) for each value produced
      Returns:
      a stream of (pseudo)randomly chosen int values, each between the specified origin (inclusive) and the specified bound (exclusive)
      Throws:
      IllegalArgumentException - if randomNumberOrigin is greater than or equal to randomNumberBound

    • ints

      default IntStream ints(long streamSize)
      Returns a stream producing the given streamSize number of (pseudo)randomly chosen int values.
      Implementation Note:
      The default implementation produces a sequential stream that repeatedly calls nextInt().
      Parameters:
      streamSize - the number of values to generate
      Returns:
      a stream of (pseudo)randomly chosen int values
      Throws:
      IllegalArgumentException - if streamSize is less than zero

    • ints

      default IntStream ints(long streamSize, int randomNumberOrigin, int randomNumberBound)
      Returns a stream producing the given streamSize number of (pseudo)randomly chosen int values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).
      Implementation Note:
      The default implementation produces a sequential stream that repeatedly calls nextInt(randomNumberOrigin, randomNumberBound).
      Parameters:
      streamSize - the number of values to generate
      randomNumberOrigin - the least value that can be produced
      randomNumberBound - the upper bound (exclusive) for each value produced
      Returns:
      a stream of (pseudo)randomly chosen int values, each between the specified origin (inclusive) and the specified bound (exclusive)
      Throws:
      IllegalArgumentException - if streamSize is less than zero, or randomNumberOrigin is greater than or equal to randomNumberBound

    • longs

      default LongStream longs()
      Returns an effectively unlimited stream of (pseudo)randomly chosen long values.
      Implementation Note:
      It is permitted to implement this method in a manner equivalent to longs (Long.MAX_VALUE). The default implementation produces a sequential stream that repeatedly calls nextLong().
      Returns:
      a stream of (pseudo)randomly chosen long values

    • longs

      default LongStream longs(long randomNumberOrigin, long randomNumberBound)
      Returns an effectively unlimited stream of (pseudo)randomly chosen long values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).
      Implementation Note:
      It is permitted to implement this method in a manner equivalent to longs (Long.MAX_VALUE, randomNumberOrigin, randomNumberBound). The default implementation produces a sequential stream that repeatedly calls nextLong(randomNumberOrigin, randomNumberBound).
      Parameters:
      randomNumberOrigin - the least value that can be produced
      randomNumberBound - the upper bound (exclusive) for each value produced
      Returns:
      a stream of (pseudo)randomly chosen long values, each between the specified origin (inclusive) and the specified bound (exclusive)
      Throws:
      IllegalArgumentException - if randomNumberOrigin is greater than or equal to randomNumberBound

    • longs

      default LongStream longs(long streamSize)
      Returns a stream producing the given streamSize number of (pseudo)randomly chosen long values.
      Implementation Note:
      The default implementation produces a sequential stream that repeatedly calls nextLong().
      Parameters:
      streamSize - the number of values to generate
      Returns:
      a stream of (pseudo)randomly chosen long values
      Throws:
      IllegalArgumentException - if streamSize is less than zero

    • longs

      default LongStream longs(long streamSize, long randomNumberOrigin, long randomNumberBound)
      Returns a stream producing the given streamSize number of (pseudo)randomly chosen long values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).
      Implementation Note:
      The default implementation produces a sequential stream that repeatedly calls nextLong(randomNumberOrigin, randomNumberBound).
      Parameters:
      streamSize - the number of values to generate
      randomNumberOrigin - the least value that can be produced
      randomNumberBound - the upper bound (exclusive) for each value produced
      Returns:
      a stream of (pseudo)randomly chosen long values, each between the specified origin (inclusive) and the specified bound (exclusive)
      Throws:
      IllegalArgumentException - if streamSize is less than zero, or randomNumberOrigin is greater than or equal to randomNumberBound

    • nextBoolean

      default boolean nextBoolean()
      Returns a (pseudo)randomly chosen boolean value.

      The default implementation tests the high-order bit (sign bit) of a value produced by nextInt(), on the grounds that some algorithms for pseudorandom number generation produce values whose high-order bits have better statistical quality than the low-order bits.

      Returns:
      a (pseudo)randomly chosen boolean value

    • nextBytes

      default void nextBytes(byte[] bytes)
      Fills a user-supplied byte array with generated byte values (pseudo)randomly chosen uniformly from the range of values between -128 (inclusive) and 255 (inclusive).
      Parameters:
      bytes - the byte array to fill with pseudorandom bytes
      Throws:
      NullPointerException - if bytes is null
      Since:
      10

    • nextFloat

      default float nextFloat()
      Returns a pseudorandom float value between zero (inclusive) and one (exclusive).

      The default implementation uses the 24 high-order bits from a call to nextInt().

      Returns:
      a pseudorandom float value between zero (inclusive) and one (exclusive)

    • nextFloat

      default float nextFloat(float bound)
      Returns a (pseudo)randomly chosen float value between zero (inclusive) and the specified bound (exclusive).
      Implementation Note:
      The default implementation simply calls checkBound(bound) and then boundedNextFloat(this, bound).
      Parameters:
      bound - the upper bound (exclusive) for the returned value. Must be positive and finite
      Returns:
      a (pseudo)randomly chosen float value between zero (inclusive) and the bound (exclusive)
      Throws:
      IllegalArgumentException - if bound is not both positive and finite

    • nextFloat

      default float nextFloat(float origin, float bound)
      Returns a (pseudo)randomly chosen float value between the specified origin (inclusive) and the specified bound (exclusive).
      Implementation Note:
      The default implementation simply calls checkBound(bound) and then boundedNextFloat(this, bound).
      Parameters:
      origin - the least value that can be returned
      bound - the upper bound (exclusive)
      Returns:
      a (pseudo)randomly chosen float value between the origin (inclusive) and the bound (exclusive)
      Throws:
      IllegalArgumentException - if origin is not finite, or bound is not finite, or origin is greater than or equal to bound

    • nextDouble

      default double nextDouble()
      Returns a pseudorandom double value between zero (inclusive) and one (exclusive).

      The default implementation uses the 53 high-order bits from a call to nextLong().

      Returns:
      a pseudorandom double value between zero (inclusive) and one (exclusive)

    • nextDouble

      default double nextDouble(double bound)
      Returns a (pseudo)randomly chosen double value between zero (inclusive) and the specified bound (exclusive).
      Implementation Note:
      The default implementation simply calls checkBound(bound) and then boundedNextDouble(this, bound).
      Parameters:
      bound - the upper bound (exclusive) for the returned value. Must be positive and finite
      Returns:
      a (pseudo)randomly chosen double value between zero (inclusive) and the bound (exclusive)
      Throws:
      IllegalArgumentException - if bound is not both positive and finite

    • nextDouble

      default double nextDouble(double origin, double bound)
      Returns a (pseudo)randomly chosen double value between the specified origin (inclusive) and the specified bound (exclusive).
      Implementation Note:
      The default implementation simply calls checkBound(bound) and then boundedNextDouble(this, bound).
      Parameters:
      origin - the least value that can be returned
      bound - the upper bound (exclusive) for the returned value
      Returns:
      a (pseudo)randomly chosen double value between the origin (inclusive) and the bound (exclusive)
      Throws:
      IllegalArgumentException - if origin is not finite, or bound is not finite, or origin is greater than or equal to bound

    • nextInt

      default int nextInt()
      Returns a (pseudo)randomly chosen int value.

      The default implementation uses the 32 high-order bits from a call to nextLong().

      Returns:
      a (pseudo)randomly chosen int value

    • nextInt

      default int nextInt(int bound)
      Returns a (pseudo)randomly chosen int value between zero (inclusive) and the specified bound (exclusive).
      Implementation Note:
      The default implementation simply calls checkBound(bound) and then boundedNextInt(this, bound).
      Parameters:
      bound - the upper bound (exclusive) for the returned value. Must be positive.
      Returns:
      a (pseudo)randomly chosen int value between zero (inclusive) and the bound (exclusive)
      Throws:
      IllegalArgumentException - if bound is not positive

    • nextInt

      default int nextInt(int origin, int bound)
      Returns a (pseudo)randomly chosen int value between the specified origin (inclusive) and the specified bound (exclusive).
      Implementation Note:
      The default implementation simply calls checkBound(bound) and then boundedNextInt(this, bound).
      Parameters:
      origin - the least value that can be returned
      bound - the upper bound (exclusive) for the returned value
      Returns:
      a (pseudo)randomly chosen int value between the origin (inclusive) and the bound (exclusive)
      Throws:
      IllegalArgumentException - if origin is greater than or equal to bound

    • nextLong

      long nextLong()
      Returns a (pseudo)randomly chosen long value.
      Returns:
      a (pseudo)randomly chosen long value

    • nextLong

      default long nextLong(long bound)
      Returns a (pseudo)randomly chosen long value between zero (inclusive) and the specified bound (exclusive).
      Implementation Note:
      The default implementation simply calls checkBound(bound) and then boundedNextLong(this, bound).
      Parameters:
      bound - the upper bound (exclusive) for the returned value. Must be positive.
      Returns:
      a (pseudo)randomly chosen long value between zero (inclusive) and the bound (exclusive)
      Throws:
      IllegalArgumentException - if bound is not positive

    • nextLong

      default long nextLong(long origin, long bound)
      Returns a (pseudo)randomly chosen long value between the specified origin (inclusive) and the specified bound (exclusive).
      Implementation Note:
      The default implementation simply calls checkBound(bound) and then boundedNextLong(this, bound).
      Parameters:
      origin - the least value that can be returned
      bound - the upper bound (exclusive) for the returned value
      Returns:
      a (pseudo)randomly chosen long value between the origin (inclusive) and the bound (exclusive)
      Throws:
      IllegalArgumentException - if origin is greater than or equal to bound

    • nextGaussian

      default double nextGaussian()
      Returns a double value (pseudo)randomly chosen from a Gaussian (normal) distribution whose mean is 0 and whose standard deviation is 1.
      Returns:
      a double value (pseudo)randomly chosen from a Gaussian distribution

    • nextGaussian

      default double nextGaussian(double mean, double stddev)
      Returns a double value (pseudo)randomly chosen from a Gaussian (normal) distribution with a mean and standard deviation specified by the arguments.
      Parameters:
      mean - the mean of the Gaussian distribution to be drawn from
      stddev - the standard deviation (square root of the variance) of the Gaussian distribution to be drawn from
      Returns:
      a double value (pseudo)randomly chosen from the specified Gaussian distribution
      Throws:
      IllegalArgumentException - if stddev is negative

    • nextExponential

      default double nextExponential()
      Returns a nonnegative double value (pseudo)randomly chosen from an exponential distribution whose mean is 1.
      Returns:
      a nonnegative double value (pseudo)randomly chosen from an exponential distribution