Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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)