# Probability that rolling X dice with Y sides and summing the highest Z values is above some value k

Some background: There is an RPG called Legend of the Five Rings, with an interesting dice system. You roll X dice, and keep the highest Z of them. You add those Z dice together. This is phrased as "X keep Z". All of the dice have ten sides, and if you roll a 10, it "explodes" (you roll again). It continues to explode until you roll something other than a ten, adding all the values together, so that one die is worth more than 10.

I'm trying to create my own RPG system, and am looking at different dice options. That said, I'd like to know how to calculate several different probabilities similar to the L5R roll and keep system:

1) What is the probability that X keep Z on Y sided dice is greater than k, with exploding dice?

2) What is the probability that X keep Z on Y sided dice is greater than k, without exploding dice?

3) What is the probability that X keep Z lowest on Y sided dice is greater than k?

• Suppose an exploding dice roll first resulted in 10, and then in 3, am I correct in concluding that its score equals 13? Commented Dec 30, 2014 at 0:25
• Yes. The value for that die would be 13. If you rolled 10, it explodes and you roll 10 again, it explodes and you roll 5, it's value is 25. Commented Dec 30, 2014 at 16:00

Let $\{S_1, \ldots, S_n\}$ be random vector of i.i.d. outcomes of the die throws. Also let $S_{k \colon n}$ denote the order statistics from that sample. The total score of the $n$-keep-$k$ scheme equals $T = \sum_{i=k+1}^n S_{i \colon n}$.

Because $S_i$ are positive discrete random variables, the technique of finding the probability generating function is the most promising: $$\mathcal{P}_T(z) = \mathbb{E}\left(z^T\right)$$ Once the probability generating function is know, probabilities of possible outcomes can be read off as series coefficients: $$\Pr(T=t) = [z^t] \mathcal{P}_T(z)$$ Moreover, the probabilites $\Pr(T \leqslant t)$ and $\Pr(T > t)$ can be read off as well: $$\Pr(T \leqslant t) = \sum_{k=0}^{t} [z^k] \mathcal{P}_T(z) = [z^t] \frac{\mathcal{P}_T(z)}{1-z}$$ $$\Pr(T > t) = 1 - \Pr(T \leqslant t) = [z^t] \frac{1 - \mathcal{P}_T(z)}{1-z}$$

For all of the cases of interest $\mathcal{P}_T(z)$ is a polynomial or rational function in $z$. But finding it requires the knowledge of the joint distribution of the order statistics $\{S_{i\colon:n}\}$.

Using Mathematica, the distribution of the total score can be found as follows:

TotalHighestScoreDistribution[{x_, z_}, dist_] :=
Block[{v},
TransformedDistribution[Total[Array[v, z]],
Distributed[Array[v, z],
OrderDistribution[{dist, x}, Range[x - z + 1, x]]]]]

TotalLowestScoreDistribution[{x_, z_}, dist_] :=
Block[{v},
TransformedDistribution[Total[Array[v, z]],
Distributed[Array[v, z], OrderDistribution[{dist, x}, Range[z]]]]]


Here I can provide the answer for explicit choices of the dice systems.

For $6$-keep-$3$ non-exploding 10-sided die:

Similarly, for the keep-lowest scores system:

The exploding die case I did by simulation, mostly because the probability generating function could not be computed in closed form:

• +1 Thanks for the information, however Mathematica solutions don't help me since I want to compare various systems, and don't have Mathematica. What happens if I make it 6 sided dice? What happens if I expect people to be rolling more/less dice, or keeping more/less dice? I may try using R to see all the distributions, or at least some of the more important ones. Commented Dec 31, 2014 at 16:27
• The only way of doing it in R would be through simulations and simulation you can write in Python, R or many other freely available packages. Commented Dec 31, 2014 at 16:30
• I meant because R has extremely easy graphing capabilities. You can do all the non-exploding portions without simulation, as well. Commented Jan 1, 2015 at 18:13