Skip to content

weightedSample

weightedSample<T>(items, weights, k): T[]

Defined in: src/global/collections.ts:212

k distinct elements, drawn in proportion to their weights.

T

Collection<T>

ArrayLike<number>

number

T[]

weightedSample(["a", "b", "c"], [1, 3, 6], 2); // [ "c", "b" ]