I know how to calculate the expected value "E" of a roll of n k-sided dice if we are supposed to keep the highest number rolled. If I am not wrong, the formula is:

E = k − (1^n + 2^n + ... + (k-1)^n)/k^n

But what I would like to know is how would affect to that expected value the following condition: every 1 that is rolled will cancel the highest remaining number rolled. If the number of 1s is at least half of the total number of dice, then the value of the roll is 0.

For example, rolling 6 10-sided die:

  • Roll #1: 7, 4, 1, 10, 1, 9 ----> The 1 cancels the 10, the second 1 cancels the 9, value of the roll is 7

  • Roll #2: 1, 9, 6, 1, 1, 3 ----> The first 1 cancels the 9, the second 1 cancels the 6, the third 1 cancels the 3, there are no more dice, the value of the roll is 0

  • Roll #3: 8, 1, 1, 1, 6, 1 ----> The first 1 cancels the 8, the second 1 cancels the 6, the only remaining dice are 1s which count as fails, so the value of the roll is 0.

As I said, I know how to calculate the expected value of the highest number in a roll of n dice, but I do not know where to start to add the condition of the 1s canceling out the highest numbers, so I would appreciate some help.

Thanks a lot.

  • 1
    $\begingroup$ I don't understand your first example, shouldn't the value be $7$? $\endgroup$
    – David
    Aug 20, 2014 at 0:38
  • $\begingroup$ You are totally right! I did not see the second 1. Editing now! $\endgroup$
    – apertotes
    Aug 20, 2014 at 3:28
  • 2
    $\begingroup$ I recommend fixing $j$, the number of $1$s rolled. For a fixed $j$, the value in question is either the $(j+1)$st largest value of $k-j$ $n$-sided dice (if $j<\frac k2$) or $0$ (if $j\ge\frac k2$). In the former case, you are looking at "order statistics" of random variables - you might even be able to derive the formula by hand. Then simply sum over all $0\le j\le k$, weighted by the probability of having $j$ 1s among $k$ dice to start with. $\endgroup$ Aug 20, 2014 at 5:33

1 Answer 1


If you go to http://topps.diku.dk/torbenm/troll.msp

and put in n:=5; m := n d10; a := count 1 = m; res := max m -- largest a m; if res then res else 0

You can brute force the answer on n dice. Note this doesn't scale real well, but if might give you an intuition.

I strongly doubt there is a clean closed form solution to this, it's likely going to be a large piecewise function using the sums of the probability of rolling k 1's for k = 0 to n/2.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .