@x82-softworks/probability-table

1.0.3 • Public • Published

probability-table

An easy way to handle probability lookup tables

Auto generated docs

https://x82-open-source.gitlab.io/npm/probability-table

import Table = from 'probability-table';

let	inst = new Table(),
	outcome;

// Percentage and the value to return 
inst.add(50,'heads');
inst.add(50,'tails');


//Accepts a number from 0 - 1 exclusive
// "tails" || "heads"
outcome = inst.get(Math.random());

inst.clear();
//The total probability need not add up to 100%
inst.add(50,'heads');

// null || "heads"
outcome = inst.get(Math.random());

//Probability tables can use double as their probabilities
inst.add(99.9999,'house_wins');
inst.add(0.0001,'you_win');

Package Sidebar

Install

npm i @x82-softworks/probability-table

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

5.52 kB

Total Files

4

Last publish

Collaborators

  • x82-softworks