Skip to main content

random_subset

Function random_subset 

Source
pub fn random_subset(
    k: &Value,
    set: &Value,
    ctx: Ctx,
    src: &mut dyn RandomSource,
) -> Result<Value, RandomError>
Expand description

RandomSubset(k, S): k pseudo-random elements of the finite set S, without repetition while k <= |S| (tlc2.module.Randomization.RandomSubset, through getRandomSubset of each set class). For k > |S| the indices wrap around and the result is all of S, as in TLC.

The result is unnormalized, as TLC builds it (new SetEnumValue(vec, false)).

§Errors

TLC’s: TLC_MODULE_ARGUMENT_ERROR when k is not an integer or S not a finite set; TLC_MODULE_VALUE_JAVA_METHOD_OVERRIDE for k < 0 (Java’s NegativeArraySizeException) and enumeration errors.