1.1.14 • Published 1 year ago

random-weighted-item v1.1.14

Weekly downloads
3
License
MIT
Repository
github
Last release
1 year ago

random-weighted-item

MIT License Build Status

NPM status

JavaScript library to get random item from an array by probability function. The probability function takes the current value and the current index respectively as arguments. The real probability to obtain a particular item is Math.exp(probabilityFunctionReturnedValue).

install

npm install --save random-weighted-item

usage

const getRandomItem = require('random-weighted-item').default;

const array = [3, 7, 1, 4, 2];
const getWeight = value => value;
getRandomItem(array, getWeight);

for other examples see https://github.com/oprogramador/random-weighted-item/blob/master/src/tests/getRandomItem.js

1.1.14

1 year ago

1.1.12

1 year ago

1.1.13

1 year ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.5

6 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago