Package-level declarations

Types

Link copied to clipboard

Predefined alphabet strings for random text generation.

Functions

Link copied to clipboard
fun Random.gaussianSequence(mean: Double = 0.0, standardDeviation: Double = 1.0): Sequence<Double>

Returns an infinite lazy sequence of normally distributed values.

Link copied to clipboard

Returns a random string of exactly length Latin letters (a-zA-Z).

Link copied to clipboard

Returns a random string of exactly length alphanumeric characters (a-zA-Z0-9).

Link copied to clipboard
fun Random.nextBoolean(probability: Double): Boolean

Returns true with the given probability and false otherwise.

Link copied to clipboard
fun Random.nextChar(alphabet: String): Char

Returns one character drawn uniformly at random from alphabet.

Link copied to clipboard
fun Random.nextDigits(length: Int): String

Returns a random string of exactly length decimal digits (0-9).

Link copied to clipboard
fun Random.nextGaussian(mean: Double = 0.0, standardDeviation: Double = 1.0): Double

Returns a normally distributed value with the given mean and standardDeviation.

Link copied to clipboard

Returns a random string of exactly length lowercase hexadecimal digits (0-9a-f).

Link copied to clipboard

Returns +1 or -1 with equal probability.

Link copied to clipboard
fun Random.nextString(length: Int, alphabet: String): String

Returns a random string of exactly length characters drawn from alphabet.

Link copied to clipboard
fun <T> randomOf(vararg options: T, random: Random = Random.Default): T

Returns one of options chosen uniformly at random.

Link copied to clipboard
fun <T> Collection<T>.sample(n: Int, random: Random = Random.Default): List<T>

Returns n elements sampled uniformly at random without replacement.

Link copied to clipboard
fun <T> Collection<T>.sampleOrNull(n: Int, random: Random = Random.Default): List<T>?

Returns n elements sampled without replacement, or null when n is out of range.

Link copied to clipboard
fun <T> Collection<T>.sampleWithReplacement(n: Int, random: Random = Random.Default): List<T>

Returns n elements sampled uniformly at random with replacement.

Link copied to clipboard
fun <T> List<T>.weightedRandom(weights: List<Double>, random: Random = Random.Default): T

Returns a random element of this list chosen with probability proportional to weights.

Link copied to clipboard
fun <T> List<T>.weightedRandomIndex(weights: List<Double>, random: Random = Random.Default): Int

Returns a random index of this list chosen with probability proportional to weights.

Link copied to clipboard
fun <T> List<T>.weightedRandomOrNull(weights: List<Double>, random: Random = Random.Default): T?

Returns a weighted random element, or null when the arguments are invalid.