Selects a random array index, biased by the provided weightings.
weightings
In the below example, a will be picked 20% of the time, b 50% and so on.
a
b
const data = [ `a`, `b`, `c`, `d` ]const weights = [ 0.2, 0.5, 0.1, 0.2 ] Copy
const data = [ `a`, `b`, `c`, `d` ]const weights = [ 0.2, 0.5, 0.1, 0.2 ]
Selects a random array index, biased by the provided
weightings
.In the below example,
a
will be picked 20% of the time,b
50% and so on.