Added in API level 35

StreamableGenerator

interface StreamableGenerator : RandomGenerator
RandomGenerator.JumpableGenerator

This interface is designed to provide a common protocol for objects that generate pseudorandom values and can easily jump forward, by a moderate amount (ex. 2

RandomGenerator.SplittableGenerator

This 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).

RandomGenerator.ArbitrarilyJumpableGenerator

This 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.

RandomGenerator.LeapableGenerator

This 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. 2

SplittableRandom

A generator of uniform pseudorandom values (with period 264) applicable for use in (among other contexts) isolated parallel computations that may generate subtasks.

The StreamableGenerator interface augments the RandomGenerator interface to provide methods that return streams of RandomGenerator objects. Ideally, such a stream of objects would have the property that the behavior of each object is statistically independent of all the others. In practice, one may have to settle for some approximation to this property.

A generator that implements interface SplittableGenerator may choose to use its java.util.random.RandomGenerator.SplittableGenerator#splits() method to implement the java.util.random.RandomGenerator.StreamableGenerator#rngs() method required by this interface.

A generator that implements interface JumpableGenerator may choose to use its jumps() method to implement the rngs() method required by this interface.

A generator that implements interface LeapableGenerator may choose to use its leaps() method to implement the rngs() method required by this interface.

Objects that implement StreamableGenerator are typically not cryptographically secure. Consider instead using SecureRandom to get a cryptographically secure pseudo-random number generator for use by security-sensitive applications.

Summary

Public methods
open static RandomGenerator.StreamableGenerator!
of(name: String!)

Returns an instance of StreamableGenerator that utilizes the name algorithm.

abstract Stream<RandomGenerator!>!

Returns an effectively unlimited stream of objects, each of which implements the RandomGenerator interface.

open Stream<RandomGenerator!>!
rngs(streamSize: Long)

Returns an effectively unlimited stream of objects, each of which implements the RandomGenerator interface.

Inherited functions
DoubleStream! doubles()

Returns an effectively unlimited stream of pseudorandomly chosen double values.

DoubleStream! doubles(randomNumberOrigin: Double, randomNumberBound: Double)

Returns an effectively unlimited stream of pseudorandomly chosen double values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).

DoubleStream! doubles(streamSize: Long)

Returns a stream producing the given streamSize number of pseudorandomly chosen double values.

DoubleStream! doubles(streamSize: Long, randomNumberOrigin: Double, randomNumberBound: Double)

Returns a stream producing the given streamSize number of pseudorandomly chosen double values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).

IntStream! ints()

Returns an effectively unlimited stream of pseudorandomly chosen int values.

IntStream! ints(randomNumberOrigin: Int, randomNumberBound: Int)

Returns an effectively unlimited stream of pseudorandomly chosen int values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).

IntStream! ints(streamSize: Long)

Returns a stream producing the given streamSize number of pseudorandomly chosen int values.

IntStream! ints(streamSize: Long, randomNumberOrigin: Int, randomNumberBound: Int)

Returns a stream producing the given streamSize number of pseudorandomly chosen int values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).

Boolean isDeprecated()

Return true if the implementation of RandomGenerator (algorithm) has been marked for deprecation.

LongStream! longs()

Returns an effectively unlimited stream of pseudorandomly chosen long values.

LongStream! longs(streamSize: Long)

Returns a stream producing the given streamSize number of pseudorandomly chosen long values.

LongStream! longs(randomNumberOrigin: Long, randomNumberBound: Long)

Returns an effectively unlimited stream of pseudorandomly chosen long values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).

LongStream! longs(streamSize: Long, randomNumberOrigin: Long, randomNumberBound: Long)

Returns a stream producing the given streamSize number of pseudorandomly chosen long values, where each value is between the specified origin (inclusive) and the specified bound (exclusive).

Boolean nextBoolean()

Returns a pseudorandomly 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.

Unit nextBytes(bytes: ByteArray!)

Fills a user-supplied byte array with generated byte values pseudorandomly chosen uniformly from the range of values between -128 (inclusive) and 127 (inclusive).

Double nextDouble()

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

Double nextDouble(bound: Double)

Returns a pseudorandomly chosen double value between zero (inclusive) and the specified bound (exclusive).

Double nextDouble(origin: Double, bound: Double)

Returns a pseudorandomly chosen double value between the specified origin (inclusive) and the specified bound (exclusive).

Double nextExponential()

Returns a nonnegative double value pseudorandomly chosen from an exponential distribution whose mean is 1.

Float nextFloat()

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

Float nextFloat(bound: Float)

Returns a pseudorandomly chosen float value between zero (inclusive) and the specified bound (exclusive).

Float nextFloat(origin: Float, bound: Float)

Returns a pseudorandomly chosen float value between the specified origin (inclusive) and the specified bound (exclusive).

Double nextGaussian()

Returns a double value pseudorandomly chosen from a Gaussian (normal) distribution whose mean is 0 and whose standard deviation is 1.

Double nextGaussian(mean: Double, stddev: Double)

Returns a double value pseudorandomly chosen from a Gaussian (normal) distribution with a mean and standard deviation specified by the arguments.

Int nextInt()

Returns a pseudorandomly chosen int value.

Int nextInt(bound: Int)

Returns a pseudorandomly chosen int value between zero (inclusive) and the specified bound (exclusive).

Int nextInt(origin: Int, bound: Int)

Returns a pseudorandomly chosen int value between the specified origin (inclusive) and the specified bound (exclusive).

Long nextLong()

Returns a pseudorandomly chosen long value.

Long nextLong(bound: Long)

Returns a pseudorandomly chosen long value between zero (inclusive) and the specified bound (exclusive).

Long nextLong(origin: Long, bound: Long)

Returns a pseudorandomly chosen long value between the specified origin (inclusive) and the specified bound (exclusive).

Public methods

of

Added in API level 35
open static fun of(name: String!): RandomGenerator.StreamableGenerator!

Returns an instance of StreamableGenerator that utilizes the name algorithm.

Parameters
name String!: Name of random number generator algorithm
Exceptions
java.lang.NullPointerException if name is null
java.lang.IllegalArgumentException if the named algorithm is not found

rngs

Added in API level 35
abstract fun rngs(): Stream<RandomGenerator!>!

Returns an effectively unlimited stream of objects, each of which implements the RandomGenerator interface. Ideally the generators in the stream will appear to be statistically independent. The new generators are of the same algorithm as this generator.

Return
Stream<RandomGenerator!>! a stream of objects that implement the RandomGenerator interface

rngs

Added in API level 35
open fun rngs(streamSize: Long): Stream<RandomGenerator!>!

Returns an effectively unlimited stream of objects, each of which implements the RandomGenerator interface. Ideally the generators in the stream will appear to be statistically independent. The new generators are of the same algorithm as this generator.

Parameters
streamSize Long: the number of generators to generate
Return
Stream<RandomGenerator!>! a stream of objects that implement the RandomGenerator interface
Exceptions
java.lang.IllegalArgumentException if streamSize is less than zero