sample

fun DoubleArray.sample(stream: RNStreamIfc = KSLRandom.defaultRNStream()): Double
fun IntArray.sample(stream: RNStreamIfc = KSLRandom.defaultRNStream()): Int
fun BooleanArray.sample(stream: RNStreamIfc = KSLRandom.defaultRNStream()): Boolean
fun <T> Array<T>.sample(stream: RNStreamIfc = KSLRandom.defaultRNStream()): T

Randomly samples an element from the array.

Parameters

stream

the stream to use for randomness


fun DoubleArray.sample(sampleSize: Int, stream: RNStreamIfc = KSLRandom.defaultRNStream()): DoubleArray
fun IntArray.sample(sampleSize: Int, stream: RNStreamIfc = KSLRandom.defaultRNStream()): IntArray
fun BooleanArray.sample(sampleSize: Int, stream: RNStreamIfc = KSLRandom.defaultRNStream()): BooleanArray

Randomly samples sampleSize elements from the array, returning a new array

Return

a new array containing the sample

Parameters

sampleSize

the size of the sample must be 1 or more


fun <T> Array<T>.sample(sampleSize: Int, stream: RNStreamIfc = KSLRandom.defaultRNStream()): MutableList<T>

Randomly samples sampleSize elements from the array, returning a new MutableList holding the same type. For now, caller can use toTypedArray() on the mutable list to get back an array at the call site.

Return

a new array containing the sample

Parameters

sampleSize

the size of the sample must be 1 or more


fun <T> MutableList<T>.sample(stream: RNStreamIfc = KSLRandom.defaultRNStream()): T

Randomly samples an element from the list.

Parameters

stream

the stream to use for randomness


fun <T> MutableList<T>.sample(sampleSize: Int, stream: RNStreamIfc = KSLRandom.defaultRNStream()): MutableList<T>

Randomly samples sampleSize elements from the list, returning a new list The elements in the list may repeat (sampling with replacement)

Return

a new array containing the sample

Parameters

sampleSize

the size of the sample must be 1 or more