Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bukinoshita/define-probability
Define probability of getting results
https://github.com/bukinoshita/define-probability
javascript math mathematics nodejs probability
Last synced: 6 days ago
JSON representation
Define probability of getting results
- Host: GitHub
- URL: https://github.com/bukinoshita/define-probability
- Owner: bukinoshita
- License: mit
- Created: 2017-06-30T18:57:03.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-04T04:50:35.000Z (over 5 years ago)
- Last Synced: 2024-10-26T13:24:25.105Z (11 days ago)
- Topics: javascript, math, mathematics, nodejs, probability
- Language: JavaScript
- Homepage:
- Size: 37.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# define-probability [![Build Status](https://travis-ci.org/bukinoshita/define-probability.svg?branch=master)](https://travis-ci.org/bukinoshita/define-probability)
> Define probability of getting results
Feel free to contribute and improve this lib.
## Install
```
$ npm install --save define-probability
```## Usage
```js
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](https://bukinoshita.io)