- All Known Subinterfaces:
- RandomGenerator.ArbitrarilyJumpableGenerator,- RandomGenerator.JumpableGenerator,- RandomGenerator.LeapableGenerator,- RandomGenerator.SplittableGenerator,- RandomGenerator.StreamableGenerator
- All Known Implementing Classes:
- Random,- SecureRandom,- SplittableRandom,- ThreadLocalRandom
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 pseudorandomly
 chosen value, or by invoking a method that returns a stream of
 pseudorandomly 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 2−w
 (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
 pseudorandomly 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 pseudorandom 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.
 
 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.
 
Unless explicit stated otherwise, the use of null for any method argument will cause a NullPointerException.
- Since:
- 17
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic interfaceThis interface is designed to provide a common protocol for objects that generate sequences of pseudorandom values and can easily jump forward, by an arbitrary amount, to a distant point in the state cycle.static interfaceThis interface is designed to provide a common protocol for objects that generate pseudorandom values and can easily jump forward, by a moderate amount (ex. 264) to a distant point in the state cycle.static interfaceThis interface is designed to provide a common protocol for objects that generate sequences of pseudorandom values and can easily not only jump but also leap forward, by a large amount (ex. 2128), to a very distant point in the state cycle.static interfaceThis interface is designed to provide a common protocol for objects that generate sequences of pseudorandom values and 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 interfaceTheRandomGenerator.StreamableGeneratorinterface augments theRandomGeneratorinterface to provide methods that return streams ofRandomGeneratorobjects.
- 
Method SummaryModifier and TypeMethodDescriptiondefault DoubleStreamdoubles()Returns an effectively unlimited stream of pseudorandomly chosendoublevalues.default DoubleStreamdoubles(double randomNumberOrigin, double randomNumberBound) Returns an effectively unlimited stream of pseudorandomly chosendoublevalues, where each value is between the specified origin (inclusive) and the specified bound (exclusive).default DoubleStreamdoubles(long streamSize) Returns a stream producing the givenstreamSizenumber of pseudorandomly chosendoublevalues.default DoubleStreamdoubles(long streamSize, double randomNumberOrigin, double randomNumberBound) Returns a stream producing the givenstreamSizenumber of pseudorandomly chosendoublevalues, where each value is between the specified origin (inclusive) and the specified bound (exclusive).static RandomGeneratorReturns aRandomGeneratormeeting the minimal requirement of having an algorithm whose state bits are greater than or equal 64.default IntStreamints()Returns an effectively unlimited stream of pseudorandomly chosenintvalues.default IntStreamints(int randomNumberOrigin, int randomNumberBound) Returns an effectively unlimited stream of pseudorandomly chosenintvalues, where each value is between the specified origin (inclusive) and the specified bound (exclusive).default IntStreamints(long streamSize) Returns a stream producing the givenstreamSizenumber of pseudorandomly chosenintvalues.default IntStreamints(long streamSize, int randomNumberOrigin, int randomNumberBound) Returns a stream producing the givenstreamSizenumber of pseudorandomly chosenintvalues, where each value is between the specified origin (inclusive) and the specified bound (exclusive).default booleanReturn true if the implementation of RandomGenerator (algorithm) has been marked for deprecation.default LongStreamlongs()Returns an effectively unlimited stream of pseudorandomly chosenlongvalues.default LongStreamlongs(long streamSize) Returns a stream producing the givenstreamSizenumber of pseudorandomly chosenlongvalues.default LongStreamlongs(long randomNumberOrigin, long randomNumberBound) Returns an effectively unlimited stream of pseudorandomly chosenlongvalues, where each value is between the specified origin (inclusive) and the specified bound (exclusive).default LongStreamlongs(long streamSize, long randomNumberOrigin, long randomNumberBound) Returns a stream producing the givenstreamSizenumber of pseudorandomly chosenlongvalues, where each value is between the specified origin (inclusive) and the specified bound (exclusive).default booleanReturns a pseudorandomly chosenbooleanvalue.default voidnextBytes(byte[] bytes) Fills a user-supplied byte array with generated byte values pseudorandomly chosen uniformly from the range of values between -128 (inclusive) and 127 (inclusive).default doubleReturns a pseudorandomdoublevalue between zero (inclusive) and one (exclusive).default doublenextDouble(double bound) Returns a pseudorandomly chosendoublevalue between zero (inclusive) and the specified bound (exclusive).default doublenextDouble(double origin, double bound) Returns a pseudorandomly chosendoublevalue between the specified origin (inclusive) and the specified bound (exclusive).default doubleReturns a nonnegativedoublevalue pseudorandomly chosen from an exponential distribution whose mean is 1.default floatReturns a pseudorandomfloatvalue between zero (inclusive) and one (exclusive).default floatnextFloat(float bound) Returns a pseudorandomly chosenfloatvalue between zero (inclusive) and the specified bound (exclusive).default floatnextFloat(float origin, float bound) Returns a pseudorandomly chosenfloatvalue between the specified origin (inclusive) and the specified bound (exclusive).default doubleReturns adoublevalue pseudorandomly chosen from a Gaussian (normal) distribution whose mean is 0 and whose standard deviation is 1.default doublenextGaussian(double mean, double stddev) Returns adoublevalue pseudorandomly chosen from a Gaussian (normal) distribution with a mean and standard deviation specified by the arguments.default intnextInt()Returns a pseudorandomly chosenintvalue.default intnextInt(int bound) Returns a pseudorandomly chosenintvalue between zero (inclusive) and the specified bound (exclusive).default intnextInt(int origin, int bound) Returns a pseudorandomly chosenintvalue between the specified origin (inclusive) and the specified bound (exclusive).longnextLong()Returns a pseudorandomly chosenlongvalue.default longnextLong(long bound) Returns a pseudorandomly chosenlongvalue between zero (inclusive) and the specified bound (exclusive).default longnextLong(long origin, long bound) Returns a pseudorandomly chosenlongvalue between the specified origin (inclusive) and the specified bound (exclusive).static RandomGenerator
- 
Method Details- 
of- Parameters:
- name- Name of random number generator algorithm
- Returns:
- An instance of RandomGenerator
- Throws:
- NullPointerException- if name is null
- IllegalArgumentException- if the named algorithm is not found
 
- 
getDefaultReturns aRandomGeneratormeeting the minimal requirement of having an algorithm whose state bits are greater than or equal 64.- Implementation Requirements:
- Since algorithms will improve over time, there is no
 guarantee that this method will return the same algorithm over time.
 The default implementation selects L32X64MixRandom. 
- Returns:
- a RandomGenerator
 
- 
isDeprecateddefault boolean isDeprecated()Return true if the implementation of RandomGenerator (algorithm) has been marked for deprecation.- Implementation Requirements:
- The default implementation checks for the @Deprecated annotation.
- Implementation Note:
- Random number generator algorithms evolve over time; new algorithms will be introduced and old algorithms will lose standing. If an older algorithm is deemed unsuitable for continued use, it will be marked as deprecated to indicate that it may be removed at some point in the future.
- Returns:
- true if the implementation of RandomGenerator (algorithm) has been marked for deprecation
 
- 
doublesReturns an effectively unlimited stream of pseudorandomly chosendoublevalues.- Implementation Requirements:
- The default implementation produces a sequential stream
 that repeatedly calls nextDouble().
- Implementation Note:
- It is permitted to implement this method in a manner equivalent to
 doubles(Long.MAX_VALUE).
- Returns:
- a stream of pseudorandomly chosen doublevalues
 
- 
doublesReturns an effectively unlimited stream of pseudorandomly chosendoublevalues, where each value is between the specified origin (inclusive) and the specified bound (exclusive).- Implementation Requirements:
- The default implementation produces a sequential stream that repeatedly
 calls nextDouble(randomNumberOrigin, randomNumberBound).
- Implementation Note:
- It is permitted to implement this method in a manner equivalent to
 doubles(Long.MAX_VALUE, randomNumberOrigin, randomNumberBound).
- Parameters:
- randomNumberOrigin- the least value that can be produced
- randomNumberBound- the upper bound (exclusive) for each value produced
- Returns:
- a stream of pseudorandomly chosen doublevalues, each between the specified origin (inclusive) and the specified bound (exclusive)
- Throws:
- IllegalArgumentException- if- randomNumberOriginis not finite, or- randomNumberBoundis not finite, or- randomNumberOriginis greater than or equal to- randomNumberBound
 
- 
doublesReturns a stream producing the givenstreamSizenumber of pseudorandomly chosendoublevalues.- Implementation Requirements:
- The default implementation produces a sequential stream
 that repeatedly calls nextDouble().
- Parameters:
- streamSize- the number of values to generate
- Returns:
- a stream of pseudorandomly chosen doublevalues
- Throws:
- IllegalArgumentException- if- streamSizeis less than zero
 
- 
doublesReturns a stream producing the givenstreamSizenumber of pseudorandomly chosendoublevalues, where each value is between the specified origin (inclusive) and the specified bound (exclusive).- Implementation Requirements:
- 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 pseudorandomly chosen doublevalues, each between the specified origin (inclusive) and the specified bound (exclusive)
- Throws:
- IllegalArgumentException- if- streamSizeis less than zero, or- randomNumberOriginis not finite, or- randomNumberBoundis not finite, or- randomNumberOriginis greater than or equal to- randomNumberBound
 
- 
intsReturns an effectively unlimited stream of pseudorandomly chosenintvalues.- Implementation Requirements:
- The default implementation produces a sequential stream
 that repeatedly calls nextInt().
- Implementation Note:
- It is permitted to implement this method in a manner
 equivalent to ints(Long.MAX_VALUE).
- Returns:
- a stream of pseudorandomly chosen intvalues
 
- 
intsReturns an effectively unlimited stream of pseudorandomly chosenintvalues, where each value is between the specified origin (inclusive) and the specified bound (exclusive).- Implementation Requirements:
- The default implementation produces a sequential stream that repeatedly
 calls nextInt(randomNumberOrigin, randomNumberBound).
- Implementation Note:
- It is permitted to implement this method in a manner equivalent to
 ints(Long.MAX_VALUE, randomNumberOrigin, randomNumberBound).
- Parameters:
- randomNumberOrigin- the least value that can be produced
- randomNumberBound- the upper bound (exclusive) for each value produced
- Returns:
- a stream of pseudorandomly chosen intvalues, each between the specified origin (inclusive) and the specified bound (exclusive)
- Throws:
- IllegalArgumentException- if- randomNumberOriginis greater than or equal to- randomNumberBound
 
- 
intsReturns a stream producing the givenstreamSizenumber of pseudorandomly chosenintvalues.- Implementation Requirements:
- The default implementation produces a sequential stream
 that repeatedly calls nextInt().
- Parameters:
- streamSize- the number of values to generate
- Returns:
- a stream of pseudorandomly chosen intvalues
- Throws:
- IllegalArgumentException- if- streamSizeis less than zero
 
- 
intsReturns a stream producing the givenstreamSizenumber of pseudorandomly chosenintvalues, where each value is between the specified origin (inclusive) and the specified bound (exclusive).- Implementation Requirements:
- 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 pseudorandomly chosen intvalues, each between the specified origin (inclusive) and the specified bound (exclusive)
- Throws:
- IllegalArgumentException- if- streamSizeis less than zero, or- randomNumberOriginis greater than or equal to- randomNumberBound
 
- 
longsReturns an effectively unlimited stream of pseudorandomly chosenlongvalues.- Implementation Requirements:
- The default implementation produces a sequential stream
 that repeatedly calls nextLong().
- Implementation Note:
- It is permitted to implement this method in a manner
 equivalent to longs(Long.MAX_VALUE).
- Returns:
- a stream of pseudorandomly chosen longvalues
 
- 
longsReturns an effectively unlimited stream of pseudorandomly chosenlongvalues, where each value is between the specified origin (inclusive) and the specified bound (exclusive).- Implementation Requirements:
- The default implementation produces a sequential stream that repeatedly
 calls nextLong(randomNumberOrigin, randomNumberBound).
- Implementation Note:
- It is permitted to implement this method in a manner equivalent to
 longs(Long.MAX_VALUE, randomNumberOrigin, randomNumberBound).
- Parameters:
- randomNumberOrigin- the least value that can be produced
- randomNumberBound- the upper bound (exclusive) for each value produced
- Returns:
- a stream of pseudorandomly chosen longvalues, each between the specified origin (inclusive) and the specified bound (exclusive)
- Throws:
- IllegalArgumentException- if- randomNumberOriginis greater than or equal to- randomNumberBound
 
- 
longsReturns a stream producing the givenstreamSizenumber of pseudorandomly chosenlongvalues.- Implementation Requirements:
- The default implementation produces a sequential stream
 that repeatedly calls nextLong().
- Parameters:
- streamSize- the number of values to generate
- Returns:
- a stream of pseudorandomly chosen longvalues
- Throws:
- IllegalArgumentException- if- streamSizeis less than zero
 
- 
longsReturns a stream producing the givenstreamSizenumber of pseudorandomly chosenlongvalues, where each value is between the specified origin (inclusive) and the specified bound (exclusive).- Implementation Requirements:
- 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 pseudorandomly chosen longvalues, each between the specified origin (inclusive) and the specified bound (exclusive)
- Throws:
- IllegalArgumentException- if- streamSizeis less than zero, or- randomNumberOriginis greater than or equal to- randomNumberBound
 
- 
nextBooleandefault boolean nextBoolean()Returns a pseudorandomly chosenbooleanvalue.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.- Implementation Requirements:
- The default implementation produces a result based on the
 sign bit of a number generated by nextInt().
- Returns:
- a pseudorandomly chosen booleanvalue
 
- 
nextBytesdefault void nextBytes(byte[] bytes) Fills a user-supplied byte array with generated byte values pseudorandomly chosen uniformly from the range of values between -128 (inclusive) and 127 (inclusive).- Implementation Requirements:
- The default implementation produces results from repeated calls
 to nextLong().
- Implementation Note:
- Algorithm used to fill the byte array;
           void nextBytes(byte[] bytes) { int i = 0; int len = bytes.length; for (int words = len >> 3; words--> 0; ) { long rnd = nextLong(); for (int n = 8; n--> 0; rnd >>>= Byte.SIZE) bytes[i++] = (byte)rnd; } if (i < len) for (long rnd = nextLong(); i < len; rnd >>>= Byte.SIZE) bytes[i++] = (byte)rnd; }
- Parameters:
- bytes- the byte array to fill with pseudorandom bytes
- Throws:
- NullPointerException- if bytes is null
 
- 
nextFloatdefault float nextFloat()Returns a pseudorandomfloatvalue between zero (inclusive) and one (exclusive).- Implementation Requirements:
- The default implementation uses the 24 high-order bits from a call to
 nextInt().
- Returns:
- a pseudorandom floatvalue between zero (inclusive) and one (exclusive)
 
- 
nextFloatdefault float nextFloat(float bound) Returns a pseudorandomly chosenfloatvalue between zero (inclusive) and the specified bound (exclusive).- Implementation Requirements:
- The default implementation checks that boundis a positive finite float. Then invokesnextFloat(), scaling the result so that the final result lies between0.0f(inclusive) andbound(exclusive).
- Parameters:
- bound- the upper bound (exclusive) for the returned value. Must be positive and finite
- Returns:
- a pseudorandomly chosen floatvalue between zero (inclusive) and the bound (exclusive)
- Throws:
- IllegalArgumentException- if- boundis not both positive and finite
 
- 
nextFloatdefault float nextFloat(float origin, float bound) Returns a pseudorandomly chosenfloatvalue between the specified origin (inclusive) and the specified bound (exclusive).- Implementation Requirements:
- The default implementation checks that originandboundare positive finite floats. Then invokesnextFloat(), scaling and translating the result so that the final result lies betweenorigin(inclusive) andbound(exclusive).
- Parameters:
- origin- the least value that can be returned
- bound- the upper bound (exclusive)
- Returns:
- a pseudorandomly chosen floatvalue between the origin (inclusive) and the bound (exclusive)
- Throws:
- IllegalArgumentException- if- originis not finite, or- boundis not finite, or- originis greater than or equal to- bound
 
- 
nextDoubledefault double nextDouble()Returns a pseudorandomdoublevalue between zero (inclusive) and one (exclusive).- Implementation Requirements:
- The default implementation uses the 53 high-order bits from a call to
 nextLong().
- Returns:
- a pseudorandom doublevalue between zero (inclusive) and one (exclusive)
 
- 
nextDoubledefault double nextDouble(double bound) Returns a pseudorandomly chosendoublevalue between zero (inclusive) and the specified bound (exclusive).- Implementation Requirements:
- The default implementation checks that boundis a positive finite double. Then invokesnextDouble(), scaling the result so that the final result lies between0.0(inclusive) andbound(exclusive).
- Parameters:
- bound- the upper bound (exclusive) for the returned value. Must be positive and finite
- Returns:
- a pseudorandomly chosen doublevalue between zero (inclusive) and the bound (exclusive)
- Throws:
- IllegalArgumentException- if- boundis not both positive and finite
 
- 
nextDoubledefault double nextDouble(double origin, double bound) Returns a pseudorandomly chosendoublevalue between the specified origin (inclusive) and the specified bound (exclusive).- Implementation Requirements:
- The default implementation checks that originandboundare positive finite doubles. Then callsnextDouble(), scaling and translating the result so that the final result lies betweenorigin(inclusive) andbound(exclusive).
- Parameters:
- origin- the least value that can be returned
- bound- the upper bound (exclusive) for the returned value
- Returns:
- a pseudorandomly chosen doublevalue between the origin (inclusive) and the bound (exclusive)
- Throws:
- IllegalArgumentException- if- originis not finite, or- boundis not finite, or- originis greater than or equal to- bound
 
- 
nextIntdefault int nextInt()Returns a pseudorandomly chosenintvalue.- Implementation Requirements:
- The default implementation uses the 32 high-order bits from a call to
 nextLong().
- Returns:
- a pseudorandomly chosen intvalue
 
- 
nextIntdefault int nextInt(int bound) Returns a pseudorandomly chosenintvalue between zero (inclusive) and the specified bound (exclusive).- Implementation Requirements:
- The default implementation checks that boundis a positiveint. Then invokesnextInt(), limiting the result to be greater than or equal zero and less thanbound. Ifboundis a power of two then limiting is a simple masking operation. Otherwise, the result is re-calculated by invokingnextInt()until the result is greater than or equal zero and less thanbound.
- Parameters:
- bound- the upper bound (exclusive) for the returned value. Must be positive.
- Returns:
- a pseudorandomly chosen intvalue between zero (inclusive) and the bound (exclusive)
- Throws:
- IllegalArgumentException- if- boundis not positive
 
- 
nextIntdefault int nextInt(int origin, int bound) Returns a pseudorandomly chosenintvalue between the specified origin (inclusive) and the specified bound (exclusive).- Implementation Requirements:
- The default implementation checks that originandboundare positiveints. Then invokesnextInt(), limiting the result to be greater that or equaloriginand less thanbound. Ifboundis a power of two then limiting is a simple masking operation. Otherwise, the result is re-calculated by invokingnextInt()until the result is greater than or equaloriginand less thanbound.
- Parameters:
- origin- the least value that can be returned
- bound- the upper bound (exclusive) for the returned value
- Returns:
- a pseudorandomly chosen intvalue between the origin (inclusive) and the bound (exclusive)
- Throws:
- IllegalArgumentException- if- originis greater than or equal to- bound
 
- 
nextLonglong nextLong()Returns a pseudorandomly chosenlongvalue.- Returns:
- a pseudorandomly chosen longvalue
 
- 
nextLongdefault long nextLong(long bound) Returns a pseudorandomly chosenlongvalue between zero (inclusive) and the specified bound (exclusive).- Implementation Requirements:
- The default implementation checks that boundis a positivelong. Then invokesnextLong(), limiting the result to be greater than or equal zero and less thanbound. Ifboundis a power of two then limiting is a simple masking operation. Otherwise, the result is re-calculated by invokingnextLong()until the result is greater than or equal zero and less thanbound.
- Parameters:
- bound- the upper bound (exclusive) for the returned value. Must be positive.
- Returns:
- a pseudorandomly chosen longvalue between zero (inclusive) and the bound (exclusive)
- Throws:
- IllegalArgumentException- if- boundis not positive
 
- 
nextLongdefault long nextLong(long origin, long bound) Returns a pseudorandomly chosenlongvalue between the specified origin (inclusive) and the specified bound (exclusive).- Implementation Requirements:
- The default implementation checks that originandboundare positivelongs. Then invokesnextLong(), limiting the result to be greater than or equaloriginand less thanbound. Ifboundis a power of two then limiting is a simple masking operation. Otherwise, the result is re-calculated by invokingnextLong()until the result is greater than or equaloriginand less thanbound.
- Parameters:
- origin- the least value that can be returned
- bound- the upper bound (exclusive) for the returned value
- Returns:
- a pseudorandomly chosen longvalue between the origin (inclusive) and the bound (exclusive)
- Throws:
- IllegalArgumentException- if- originis greater than or equal to- bound
 
- 
nextGaussiandefault double nextGaussian()Returns adoublevalue pseudorandomly chosen from a Gaussian (normal) distribution whose mean is 0 and whose standard deviation is 1.- Implementation Requirements:
- The default implementation uses McFarland's fast modified ziggurat algorithm (largely table-driven, with rare cases handled by computation and rejection sampling). Walker's alias method for sampling a discrete distribution also plays a role.
- Returns:
- a doublevalue pseudorandomly chosen from a Gaussian distribution
 
- 
nextGaussiandefault double nextGaussian(double mean, double stddev) Returns adoublevalue pseudorandomly chosen from a Gaussian (normal) distribution with a mean and standard deviation specified by the arguments.- Implementation Requirements:
- The default implementation uses McFarland's fast modified ziggurat algorithm (largely table-driven, with rare cases handled by computation and rejection sampling). Walker's alias method for sampling a discrete distribution also plays a role.
- 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 doublevalue pseudorandomly chosen from the specified Gaussian distribution
- Throws:
- IllegalArgumentException- if- stddevis negative
 
- 
nextExponentialdefault double nextExponential()Returns a nonnegativedoublevalue pseudorandomly chosen from an exponential distribution whose mean is 1.- Implementation Requirements:
- The default implementation uses McFarland's fast modified ziggurat algorithm (largely table-driven, with rare cases handled by computation and rejection sampling). Walker's alias method for sampling a discrete distribution also plays a role.
- Returns:
- a nonnegative doublevalue pseudorandomly chosen from an exponential distribution
 
 
-