0

I'm looking for a formula to calculate the chance that (n) rolls of a d(y) produces any of (x) specific numbers (k) times, where x,y,n,k > 0, k <= n, and x <= y.

AnyDice is a neat thing to know about, but I'd much rather have the formula itself.

I know this sounds like stat homework but I guarantee you it's for tabletop shenanigans. I recently ran a one-shot combining Hack The Planet, the one page 90's hacker rpg created by Grant Howitt, and D&D 5e, to create a sort of... Persona'esc experience. I created this table:

Difficulty Table

...to handle contesting rolls between the system. It worked well enough for a one shot but it seemed rolls with 5e's d20 system generally had a leg up over hack the planet's d6's. I'm asking for this formula in order to assist in better balancing any other hackbrained one-shot ideas I think up in the future.

Midas
  • 19
  • 4

1 Answers1

2

First start with a single d(y). On a single roll, the probability of rolling among the \$x\$ of \$y\$ values is calculated as \$x/y\$. Let's say this is an event with probability \$p=x/y\$.

For multiple dice, you start dealing with Binomial distribution probabilities. To find the probability that the event occurs exactly \$k\$ of \$n\$ times, we use the formula for Bernoulli trials and use the combination function C.

The probability of the event occurring exactly \$k\$ of \$n\$ times is $$C(n,k) \cdot p^k \cdot (1-p)^{(n-k)} = C(n,k) \cdot (x/y)^k \cdot (1-x/y)^{(n-k)}$$

For the probability of this event occurring at least \$k\$ out of \$n\$ times, you need a binomial cumulative density function. It's the probability of the event occurring \$k\$ out of \$n\$ times, plus the probability of the event occurring \$k+1\$ out of \$n\$ times, and so on, plus the probability of the event occurring \$n\$ out of \$n\$ times.

The formula for this cumulative probability is $$\sum_{i=k}^{n} ~C(n,i) \cdot p^i \cdot (1-p)^{(n-i)} = \sum_{i=k}^{n} ~C(n,i) \cdot (x/y)^i \cdot (1-x/y)^{(n-i)}$$

MikeQ
  • 31,494
  • 8
  • 97
  • 167