RandomChoice
[items]RandomChoice
[items, n]RandomChoice
[items, {$n_1$, $n_2$, ...}]RandomChoice
[weights -> items, n]RandomChoice
[weights -> items]RandomChoice
[weights -> items, {$n_1$, $n_2$, ...}] Note: SeedRandom
is used below so we get repeatable “random” numbers that we can test.
SeedRandom[42]
RandomChoice[{a, b, c}]
SeedRandom[42] (* Set for repeatable randomness *)
RandomChoice[{a, b, c}, 20]
SeedRandom[42]
RandomChoice[{"a", {1, 2}, x, {}}, 10]
SeedRandom[42]
RandomChoice[{a, b, c}, {5, 2}]
SeedRandom[42]
RandomChoice[{1, 100, 5} -> {a, b, c}, 20]