weighted-pick
v1.0.2
Published
A library to pick random elements with weighted probability.
Downloads
14
Maintainers
Readme
A library to pick random elements with weighted probability
Algorithm Visualization
Usage
const { WeightedValue, WeightedPick } = require('weighted-pick');
const picker = new WeightedPick([
new WeightedValue(0, 1),
new WeightedValue(1, 1)
]);
const n = 1000;
const values = picker.pickValues(n);