To quickly sum up the reasoning for this question to give context I'm creating a table of probabilities for a RPG using a roll and keep system similar to legend of the five rings. I need to find the probability of rolling equal too or above above a given value when rolling Y d10s, keeping the Z number of dice that had the highest result, and adding the results of those Z dice together. As an example I would need to find the odds of rolling 7 dice, taking the 4 dice with the highest result, and having the sum of those dice be equal to or above 15. I've tried various online sites and calculators like AnyDice but the site can't calculate the higher end results I need to find, in this case rolling 18 d10 and keeping the highest 6. I essentially need to find the probability for meeting or exceeding each possible result for every rules legal combination of dice rolled and dice kept. Thank you for taking the time to read this.
1 Answers
The simple answer
Here's a JupyterLite notebook on Legend of the Five Rings.
If you don't use exploding dice, you might prefer the interface of my Cortex Prime calculator.
The complicated answer
That the sum of a set of dice can be computed via convolution is a classical result in discrete statistics. Convolution (sometimes also framed in terms of generating functions) allows us to use the fantastically efficient fast Fourier transform (FFT). With some more work, this can be extended to the case where only some of the dice are kept. Approaches of this type have been proposed on StackExchange, with examples including:
- Formula for dropping dice (non-brute force)
- Generating Function for sum of N dice [or other multinomial distribution] where lowest N values are "dropped" or removed
The other major type of approach is dynamic programming (sometimes also framed in terms of recurrence relations). Examples include:
- Roll and Keep in Anydice
- How to calculate the probabilities for eliminative dice pools (dice cancelling mechanic) in Neon City Overdrive?
The short of it is that we compute the answer to the problem to "roll $n$ d10, keep $m$" by considering how many dice $k = 0 \ldots n$ might possibly roll a 10, and then use the solutions to "roll $n - k$ d9, keep $m - k$" -- namely, the remaining pool after the $k$ dice that rolled a 10 are removed -- to complete the solution. In turn, the solutions for d9s use the solutions for d8s, and so forth until we reach d1s and all of the remaining dice must roll 1. While not as fast as FFTs, the dynamic programming approach is much more flexible, covering general "single-pass" functions over order statistics: in addition to summing the dice, it can also be used to produce efficient solutions for matching sets, straights, RISK-like mechanics, and so forth.
If you are interested in learning more, you can read my paper on the subject, or try my Icepool Python package, which is what powers the apps in the first two links.
@inproceedings{liu2022icepool,
title={Icepool: Efficient Computation of Dice Pool Probabilities},
author={Albert Julius Liu},
booktitle={Eighteenth AAAI Conference on Artificial Intelligence and Interactive Digital Entertainment},
volume={18},
number={1},
pages={258-265},
year={2022},
month={Oct.},
eventdate={2022-10-24/2022-10-28},
venue={Pomona, California},
url={https://ojs.aaai.org/index.php/AIIDE/article/view/21971},
doi={10.1609/aiide.v18i1.21971}
}
- 940