SkillAgentSearch skills...

Sampling

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

Install / Use

/learn @mfornos/Sampling
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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

View on GitHub
GitHub Stars7
CategoryDevelopment
Updated3y ago
Forks3

Languages

JavaScript

Security Score

70/100

Audited on Feb 11, 2023

No findings