define-probability
v0.0.1
Published
Define probability of getting results
Downloads
14
Maintainers
Readme
define-probability
Define probability of getting results
Feel free to contribute and improve this lib.
Install
$ npm install --save define-probability
Usage
const defineProbability = require('define-probability')
const probabilities = [
{ value: 'male', prob: .2 },
{ value: 'female', prob: .8 }
]
defineProbability(probabilities)
// => female
API
defineProbability(entry)
returns value
.
entry
Type: array
Required
Array
must have at least 2 entries and must have value
and prob
keys.
Where value
is the value returned and prob the probabilities of getting this result. value
is a number between 0 and 1.
License
MIT © Bu Kinoshita