Package-level declarations

Types

Link copied to clipboard
class DefaultGenerator(val random: Random = Random) : RandomGenerator

Implements RandomGenerator by delegating all operations to Random.

Link copied to clipboard
class MCScope(val coroutineContext: CoroutineContext, val random: RandomGenerator)

A scope for a Monte-Carlo computations or multi-coroutine random number generation. The scope preserves the order of random generator calls as long as all concurrency calls is done via launch and async functions.

Link copied to clipboard
class RandomChain<out R>(val generator: RandomGenerator, gen: suspend RandomGenerator.() -> R) : Chain<R>

A possibly stateful chain producing random values.

Link copied to clipboard
interface RandomGenerator

An interface that is implemented by random number generator algorithms.

Link copied to clipboard

A type-specific double chunk random chain

Functions

Link copied to clipboard
Link copied to clipboard
inline fun <T> MCScope.async(context: CoroutineContext = EmptyCoroutineContext, start: CoroutineStart = CoroutineStart.DEFAULT, crossinline block: suspend MCScope.() -> T): Deferred<T>

Specialized async for MCScope. Behaves the same way as regular CoroutineScope.async, but also stores the generator fork. The method itself is not thread safe.

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
inline fun MCScope.launch(context: CoroutineContext = EmptyCoroutineContext, start: CoroutineStart = CoroutineStart.DEFAULT, crossinline block: suspend MCScope.() -> Unit): Job

Specialized launch for MCScope. Behaves the same way as regular CoroutineScope.launch, but also stores the generator fork. The method itself is not thread safe.

Link copied to clipboard
inline suspend fun <T> mcScope(seed: Long, block: MCScope.() -> T): T

Launch mc scope with a given seed

inline suspend fun <T> mcScope(generator: RandomGenerator, block: MCScope.() -> T): T

Launches a supervised Monte-Carlo scope