DefaultGenerator

class DefaultGenerator(val random: Random = Random) : RandomGenerator(source)

Implements RandomGenerator by delegating all operations to Random.

Constructors

Link copied to clipboard
constructor(random: Random = Random)

Functions

Link copied to clipboard
fun RandomGenerator.asUniformRandomProvider(): UniformRandomProvider

Represent this RandomGenerator as commons-rng UniformRandomProvider preserving and mirroring its current state. Getting new value from one of those changes the state of another.

Link copied to clipboard
fun <R> RandomGenerator.chain(generator: suspend RandomGenerator.() -> R): RandomChain<R>

Create a generic random chain with provided generator

Link copied to clipboard
open override fun fillBytes(array: ByteArray, fromIndex: Int, toIndex: Int)

Fills a subrange with the specified byte array starting from fromIndex inclusive and ending toIndex exclusive with random bytes.

Link copied to clipboard
open override fun fork(): RandomGenerator

Create a new generator that is independent of current generator (operations on new generator do not affect this one and vise versa). The statistical properties of new generator should be the same as for this one. For pseudo-random generator, the fork is keeping the same sequence of numbers for given call order for each run.

Link copied to clipboard
open override fun nextBoolean(): Boolean

Gets the next random Boolean value.

Link copied to clipboard
open override fun nextBytes(size: Int): ByteArray

Creates a byte array of the specified size, filled with random bytes.

Link copied to clipboard
open override fun nextDouble(): Double

Gets the next random Double value uniformly distributed between 0 (inclusive) and 1 (exclusive).

Link copied to clipboard

A chunk of doubles of given size.

Link copied to clipboard
open override fun nextInt(): Int

Gets the next random Int from the random number generator.

open override fun nextInt(until: Int): Int

Gets the next random non-negative Int from the random number generator less than the specified until bound.

Link copied to clipboard
open override fun nextLong(): Long

Gets the next random Long from the random number generator.

open override fun nextLong(until: Long): Long

Gets the next random non-negative Long from the random number generator less than the specified until bound.

Properties

Link copied to clipboard

the underlying Random object.