Roman said:
Thanks! This is indeed useful.
Just to expand on the question: How did you obtain the (2k-1) part of the formula?
How many ways can you get less than or equal to k? Since both dice must independently be less than or equal to k, there are k^2 ways that can happen.
How many ways can you get strictly less than k? That means less than or equal to k-1, so there are (k-1)^2 ways.
How many ways to get exactly k? That means less than or equal to k but not less than or equal to k-1. So subtract:
k^2 - (k-1)^2 = k^2 - (k^2-2k+1) = 2k-1.
Roman said:
Also, is can this be generalized for multiple (more than two) rolls keep the highest,
Sort of. You can apply similar reasoning, but the formulas become more complicated.
For three dice, the number of ways (out of n^3) to get exactly k will be
k^3 - (k-1)^3
= k^3 - (k^3 - 3k^2 + 3k -1)
= 3k^2 - 3k + 1
Likewise, at this stage, if you have m dice, and want to keep only the best single die roll, you'll have a polynomial of degree (m-1) to deal with.
Now, with two dice, notice that I needed to know the formulas for sums from k=1 to k=n
sum(k) = n(n+1)/2
sum(k^2)=n(n+1)(2n+1)/6
Well, with three dice, I'm also going to need to know
sum(k^3)=[n(n+1)/2]^2
and with four dice I'm going to to know the formula for sum(k^4), which I'd have to look up. One of the Bernoulli brothers figured out all of these sums back in the 17th century, but apart from sum(k) (which the ancient Greeks knew), they aren't easy. (The formula for sum(k) was famously rediscovered by an 8-year-old Carl Gauss; most 8-year-olds aren't up to rediscovering it themselves, but you can show Gauss' reasoning to any mathematically competent middle school student and they'll at least be able to follow it. Not so with any proof I know of sum(k^2) or higher.)
Actually, for a specific die, if you don't want the general formula, you can do it without the algebra. Just calculate the 20 (or however many sides on the die) probabilities independently, and then add. For a big die it's a lot of numbers, but you don't need to know the Bernoulli formulas. If you want to do as I did, give a formula for n-sided dice without specifying a particular value of n, you'll need the Bernoulli formulas.
Roman said:
multiple rolls drop the lowest or even multiple rolls drop X rolls?
That's a lot trickier. I can't think of an elegant way to compute all the probabilities you need systematically. When I wanted to figure out the distribution for best 3 out of 4 d6, I set up a spreadsheet to enumerate all 6^4=1296 possibilities and calculate the sum for each.