weightedSample
weightedSample<
T>(items,weights,k):T[]
Defined in: src/global/collections.ts:212
k distinct elements, drawn in proportion to their weights.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”Collection<T>
weights
Section titled “weights”ArrayLike<number>
number
Returns
Section titled “Returns”T[]
Example
Section titled “Example”weightedSample(["a", "b", "c"], [1, 3, 6], 2); // [ "c", "b" ]