Skip to content

Sampling of random values from a discrete probability distribution, using the Walker-Vose alias method.

License

Notifications You must be signed in to change notification settings

mfornos/sampling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alias Method for Sampling

Library for sampling of random values from a discrete probability distribution, using the Walker-Vose alias method.

NPM

Usage

var s = sample([0.5, 0.25, 0.25], ['A', 'B', 'C']);
s.next(); // => random outcome according to specified probabilities
var s = sample([0.5, 0.25, 0.25], [10, 20, 30]);
s.next(1000); // => 1000 random samples according to specified probabilities
var s = sample([0.5, 0.25, 0.25]);
s.next(); // => random index according to specified probabilities

Have fun!

Build Status

About

Sampling of random values from a discrete probability distribution, using the Walker-Vose alias method.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published