Die rolling and probability question

I’d like to ask the math/statistics experts on the board for help on some die-rolling probabilities. Please help me understand how to do these types of calculations.

Rolling X dice and picking the X-1 highest/lowest. How do I calculate the expected result? How do I check the probability of the roll being less/more than a certain number?

For example rolling 3 dice and picking the two highest what is my chance of getting more than 8? How do I calculate the expected sum of that roll?

Actually calculating the probability of the sum of the dice gets quite involved with higher numbers of dice. This would be a somewhat easy computer program to write though.

X = number of dice; /* X > 0 /
int total[6
X]; /* array is bigger than we need */

/* lets do X = 3 for example */
for (a=1, a<7, a++) {
for (b=1, b<7, b++) {
for (c=1, c<7, c++) {
sum = sum(a,b,c) - min(a,b,c);
total[sum]++;
}
}
}

print ("Number of dice = " X);

for (ax=X-1, ax<=6*(X-1), ax++) {
print ("probability of roll = " ax " is " total[ax] " in " ((6*(X-1)) - (X-1)) ));
}

Update Patch #1: :slight_smile:

The value in the last line: (6*(X-1)) - (X-1)) should be (6*(X-1)) - (X-2)), this is the total number of outcomes with X dice.

This part is actually not that hard to compute, but the formula takes a little understanding. What you want to do is compute the expected value of the lowest (or highest) die. As an example I’ll do it for X = 3, and choosing the 2 lowest.

All together, there are 216 (= 6[sup]X[/sup]) combinations.
There is 1 possible combo where 1 is the highest - 111.
There are 7 where 2 is the highest - 112, 121, 122, 211, 212, 221, 222.
There are 19 where 3 is the highest.

In general, there will be k[sup]X[/sup] - (k-1)[sup]X[/sup] where k is the highest. I can explain this more if you don’t see why.

So the expected value of the highest die is just SUM(k(k[sup]X[/sup] - (k-1)[sup]X[/sup]), k = 1…6) / 216. For X = 3, this is 119/24 = 4.958. Now you know the average total is 3.5X = 10.5. So the average after subtracting the highest die is 5.542.

It’s possible to simplify that sum somewhat, depending on what you want it to look like. I have a form with binomial coefficients, which may be more or less simple depending on how you like to do it. Anyway, if you instead want to use the X-1 highest dice, the expected value for the lowest die is:

SUM(k((7-k)[sup]X[/sup] - (6-k)[sup]X[/sup]), k = 1…6) / 216

For X = 3, the two highest dice have an expected value of 8.458. Not surprisingly, this is also equal to 7(X-1) - 5.542, where 5.542 is the answer from before.

Unable to come up with a simple formula, I went ahead and wrote a program to do it. Put this in an HTML file, and it should run in your browser window. X=3 runs in a trivial amount of time, but it took about 12 seconds to run X=6, and I wasn’t patient enough for X=8.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
<html lang="en-US" xml:lang="en-US"><head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<meta http-equiv="Content-Language" content="en-us" />
<title>Rolling the Dice</title>
<script type="text/javascript">
function Compute() {
  calc = document.forms[0]
  X = calc.x.value
  n = calc.n.value
  k = calc.k.value
  die = new Array(X); for (j = 0; j < X; ++j) die[j] = 1
  L = total = 0; part = [0, 0, 0]
  Count = Math.pow(n, X)  
  do {
    min = max = die[0]; sum = 0
    for (j in die) {
      if (min > die[j]) min = die[j]
      if (max < die[j]) max = die[j]
      sum += die[j]; }
    total += (sum -= calc.remove[0].checked ? min : max)
    ++part[sum < k ? 0 : (sum > k ? 2 : 1)]
    ++die[0]
    for (j in die) if (die[j] > n) { die[L = j] = 1; ++die[parseInt(j)+1]; }
  } while (L < X - 1)
  calc.average.value = total / Count
  calc.less.value = part[0] / Count
  calc.equal.value = part[1] / Count
  calc.greater.value = part[2] / Count
}
</script></head><body>
<form action="" id="calculon"><p>
Number of dice (X): <input name="x" value="3" size="2" /><br />
Sides per die (n): <input name="n" value="6" size="2" /><br />
Goal value (k): <input name="k" value="8" size="2" /><br />
<input type="radio" name="remove" value="min" checked="checked" /> Remove lowest roll<br />
<input type="radio" name="remove" value="max" /> Remove highest roll<br />
<button type="button" onclick="Compute()">Compute!</button><br /><br />
Average: <input name="average" value="" size="10" /><br />
Fraction less than k: <input name="less" value="" size="10" /><br />
Fraction equal to k: <input name="equal" value="" size="10" /><br />
Fraction greater than k: <input name="greater" value="" size="10" /><br />
</p></form>
</body>
</html>

Thanks Achernar that was great.

May I ask you to expand on this, so that I hopefully may be able to understand and replicate the calculation myself.

FWIW, Coil, in your last post where you quote Achernar, the X’s do not appear as superscripts, so the formula in your quote is not correct.

If I may attempt to answer for Achernar, the easiest way to find the probability of the highest of X dice equalling a number K is by recognizing that this is equal to the probability of the highest die being K or less, minus the probability of the highest die being less than K.

The odds of one die being K or less is (K/N). For the highest of X dice to be K or less, all dice must be K or less, and the odds of that are (K/N) to the X. For example, the odds of the highest of 3 six-sided dice (can I assume we’re all gamers enough to just say 3d6?) being 5 or less is (5/6) cubed or 125/216. That is, there are 125 ways to roll 3d6 and not get any 6’s. But not all of those rolls include a 5. There are (4/6) cubed or 64 ways to roll 3d6 and not get any 5’s or 6’s. So the number of rolls that contain at least one 5 and no 6’s is 125 - 64 or 61, and the odds of 5 being the highest number rolled is 61/216.

If your web browser can run Java, http://www.drizzle.com/~keitha/DieGraph.html may be helpful, especially if you ever want to drop highest/lowest 2 or more dice from a larger roll.