Skip to content

timheiko/weighted-pick

 
 

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

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 95.1%
  • TypeScript 4.9%