The random library

Some functions for random sampling

Synopsis

choose :: for_type a: (List(a)) -> List(a)
pick :: for_type t: (List(t)) -> t
random_nat :: (1) -> 1
sample :: for_type a: (List(a), 1) -> List(a)
shuffle :: for_type a: (List(a)) -> List(a)

Functions

choose

:: for_type a: (List(a)) -> List(a)

Random sublist/subset of the list. For each element it flips a coin to see whether it stays, or is removed.

pick

:: for_type t: (List(t)) -> t

Picks a random elements from a list. Each element is equally likely.

random_nat

:: (1) -> 1

Random natural number below n. Parameter n must be a non-zero natural number.

sample

:: for_type a: (List(a), 1) -> List(a)

Random sublist/subset of a specific size. For each element it is equally likely that it stays, or is removed.

shuffle

:: for_type a: (List(a)) -> List(a)

A random permutation of a list. Each permutation is equally likely.

Version v0.6.0, 2026-03-05T15:49:26.576138724+01:00[Europe/Amsterdam]