0.0.1 • Published 7 years ago

define-probability v0.0.1

Weekly downloads
8
License
MIT
Repository
github
Last release
7 years ago

define-probability Build Status

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