Skip to content

Repository files navigation

A library to pick random elements with weighted probability

Algorithm Visualization

WeightedPick WeightedPick

Usage

TypeScript

import {WeightedPick} from 'weighted-pick';

const picker = new WeightedPick([
    {value: 0, weight: 1},
    {value: 1, weight: 1},
]);

const values = picker.pickValues(5);

JavaScript

import {WeightedValue, WeightedPick} from 'weighted-pick';

const picker = new WeightedPick([
    new WeightedValue(0, 1),
    new WeightedValue(1, 1),
]);

const values = picker.pickValues(5);

Based on

About

A library to pick random elements with weighted probability

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages