Socket
Socket
Sign inDemoInstall

@apocentre/alias-sampling

Package Overview
Dependencies
0
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @apocentre/alias-sampling

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


Version published
Weekly downloads
22K
decreased by-19.34%
Maintainers
3
Install size
24.7 kB
Created
Weekly downloads
 

Readme

Source

Alias Method for Sampling

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

Installation

yarn add @apocentre/aliasing

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
var rand = Math.rand; // custom random generator function
var s = sample([0.5, 0.25, 0.25], null, rand);
s.next(); // => random index according to specified probabilities

Have fun!

Build Status

Keywords

FAQs

Last updated on 15 Feb 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc