# Probabilities of the second highest roll in a dice pool.

I've been trying to figure out the probabilities of rolling a specific number in a pool of 4 20-sided dice, assuming I discard the highest and two lowest rolls. My instinct was to compound the probabilities of two dice being lower or equal to a target n, one being higher or equal, and one being the specific roll I want, like so $$P(n) = \frac{(n^2)(21-n)}{20^4}$$.

However, I noticed that the sum of the probabilities for each numbers was only ~10% instead of a flat 1. My first instinct was that this was the probability of a specific dice being the second highest, so not all outcomes were accounted for, but factoring in permutations brought me to ~242%. Still not close. Is this a case where the sum of the individual probabilities doesn't need to equal 1, or is my math wrong and where?.

• Your formula does not appear to allow for permutations. Non-trivial, in this case, since , say, $\{11,11,11,11\}$ has no non-trivial permutations while $\{1,2,3,4\}$ has $24$. – lulu Jan 21 at 20:05
• Thanks, I had an intuition that I had to do with permutations, but that some should be dropped. If someone has a resource on how to factor those in an equation, that'd be awesome. – FnTom Jan 21 at 20:21
• Do you need an exact answer? Simulation is easy. If you need something exact, I guess I'd break it into cases. First do the case where all four rolls are distinct, that's pretty easy. Then look at the various ways to get duplicates. And so on. A little tedious, but there really aren't all that many cases. I'd still simulate it though, so you can check the combinatorial solution. – lulu Jan 21 at 21:15
• Should say: there could, of course, be some clever way that I'm not seeing at the moment. – lulu Jan 21 at 21:16
• If I understand what you’re asking for correctly, you’re interested in an order statistic of the set of random variables representing the individual die rolls. You can find a gloss in this Wikipedia article, and for your application in particular, there are explicit formulas in this section that you can use for computation. The PMF and CDF of a discrete uniform distribution are rather simple. Or you could code this up in AnyDice. – amd Jan 22 at 9:37

The probability for the highest die to show $$k$$ and all other dice to show at most $$n\lt k$$ is $$4\cdot\frac{n^3}{20^4}$$, so the probability for the highest die to show $$k$$ and the next highest die to show $$n\lt k$$ is $$4\cdot\frac{n^3-(n-1)^3}{20^4}$$. So the probability for the second-highest die to be lower than the highest and have the value $$n$$ is

$$4\sum_{k=n+1}^{20}\frac{n^3-(n-1)^3}{20^4}=4(20-n)\frac{n^3-(n-1)^3}{20^4}\;,$$

whereas the probability for the second-highest die to be equal to the highest and have the value $$n$$ is

$$\frac{n^4-(n-1)^4-4(n-1)^3}{20^4}\;.$$

The probability you seek is the sum of those two probabilities,

$$\frac{4(20-n)\left(n^3-(n-1)^3\right)+n^4-(n-1)^4-4(n-1)^3}{20^4}=\frac{83-252n+258n^2-12n^3}{20^4}\;.$$

Here's a table of the numerators for $$n=1,\ldots,20$$:

$$\begin{array}{r|r} n&\\\hline 1&77\\ 2&515\\ 3&1325\\ 4&2435\\ 5&3773\\ 6&5267\\ 7&6845\\ 8&8435\\ 9&9965\\ 10&11363\\ 11&12557\\ 12&13475\\ 13&14045\\ 14&14195\\ 15&13853\\ 16&12947\\ 17&11405\\ 18&9155\\ 19&6125\\ 20&2243 \end{array}$$