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.


marked as duplicate by Rykara, Oblivious Sage, Xirema, Ilmari Karonen, KorvinStarmast May 21 at 21:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • \$\begingroup\$ Are you needing the formula specifically, or just a way to figure out the results? There are websites out there that do this. \$\endgroup\$ – Ben Barden May 21 at 20:33
  • 1
    \$\begingroup\$ When you say "(k) times", do you mean exactly (k) times, or at least (k) times? \$\endgroup\$ – MikeQ May 21 at 20:33
  • 1
    \$\begingroup\$ Welcome to the site! Please take our tour to get an idea for how things work here. Could you elaborate on what tabletop shenanigans you want them for? The more information you can provide the better answers our experts can give. There may be a solution to your specific problem other than a general formula that you haven't foreseen \$\endgroup\$ – David Coffron May 21 at 20:34
  • 2
    \$\begingroup\$ I'm voting to close this question as off-topic because I believe it is a better fit for the Mathematics Stack Exchange due to this meta discussion. \$\endgroup\$ – Rykara May 21 at 20:37
  • 2
    \$\begingroup\$ Anyway, the answer can be found on Wikipedia. \$\endgroup\$ – Ilmari Karonen May 21 at 20:46

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)}$$


Not the answer you're looking for? Browse other questions tagged or ask your own question.