(rand-weighted ..args) args: two or more arguments (any type) returns any type
F
Randomly selects one item from a group, with unequal probability.
Expects an even number of arguments, where the even-numbered arguments are all non-negative numbers (weights). The sum of all weights must be greater than 0.
Each argument's likelihood of being chosen is equal to (/ weight sum)
. For example,
(rand-weighted 'x 2 'y 3 'z 0)
has a two-in-five chance of returning 'x
and a
three-in-five chance of returning 'y
. It will never return 'z
.