dice-probabilities

1.0.0 • Public • Published

Dice Probabilities

Compute the probability of rolling p on n s-sided dice.

The formula for the probability comes from Wolfram; the multiplicative formula for the binomial coefficient comes from Wikipedia.

This page is just interesting: http://mathforum.org/library/drmath/view/52207.html

Installation

Usage

This module provides one function to compute the probability of rolling a specific number and another to roll dice.

const dice_prob = require('dice-probabilities');

// Probability for rolling 12 on 2 6-sided dice:
let p = dice_prop.P(12, 2, 6);

// Cumulative probability for rolling under 11 on 3 6-sided dice:
let cp = 0.0;
for (let i = 3; i <= 18; i++) {
  cp += dice_prop.P(i, 3, 6);
}

let r = dice_prop.roll(2, 6);

Readme

Keywords

Package Sidebar

Install

npm i dice-probabilities

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

3.65 kB

Total Files

5

Last publish

Collaborators

  • mcguire