Returns an infinite iterator of random choices and their (optional) weights. If weights is given, it must have at least the same size as choices. If omitted, each choice will have same probability.
weights
choices
-
transduce(take(1000), frequencies(), choices("abcd", [1, 0.5, 0.25, 0.125])) // Map { 'c' => 132, 'a' => 545, 'b' => 251, 'd' => 72 }
{@link @thi.ng/random#weightedRandom}
Generated using TypeDoc
Returns an infinite iterator of random choices and their (optional) weights. If
weights
is given, it must have at least the same size aschoices
. If omitted, each choice will have same probability.-
transduce(take(1000), frequencies(), choices("abcd", [1, 0.5, 0.25, 0.125])) // Map { 'c' => 132, 'a' => 545, 'b' => 251, 'd' => 72 }
{@link @thi.ng/random#weightedRandom}