View Full Version : Quick math question

Kane0

2019-09-25, 08:04 PM

If I can reroll one die on a damage roll, what does that make the average damage?

So for example every attack deals +1d4 damage and I get to reroll the +1d4, taking the best of the two rolls. Instead of an average +2.5 damage per hit what does it become?

Ideally I'd like to know for d4, d6, d8, d10 and d12, i'm having a terrible math day.

JNAProductions

2019-09-25, 08:22 PM

If I can reroll one die on a damage roll, what does that make the average damage?

So for example every attack deals +1d4 damage and I get to reroll the +1d4, taking the best of the two rolls. Instead of an average +2.5 damage per hit what does it become?

Ideally I'd like to know for d4, d6, d8, d10 and d12, i'm having a terrible math day.

It's easy to figure out, if a lil' tedious with my method.

Replace any roll of less than the average with the average, then average all them.

So d4 would, instead of:

1

2

3

4

be, in fact:

2.5

2.5

3

4

The first sums to 10, divide by 4 to get 2.5.

The second sums to 12, divide by 4 to get 3.

Ah crap, yeah. I goofed.

Composer99

2019-09-25, 08:22 PM

There's probably a simple formula, but here's the crunching for d4s:

For d4s, you get the following outcomes:

1 "1" result: 1,1

3 "2" results: 1,2 or 2,1 or 2,2

5 "3" results: 1,3 or 3,1 or 3,2 or 2,3 or 3,3

7 "4" results: 1,4 or 4,1 or 4,2 or 2,4 or 4,3 or 3,4 or 4,4

So you get the number series 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, which, has the average of 3.125.

You could do the same thing for each of the other dice sizes, though obviously it would get annoying to do by hand for larger dice. I imagine a spreadsheet or, even better, a formula, would make it easier.

(Edited for corrections - I had one "4" too many.)

More Edit:

It looks like there is a pattern, that might make it easier: you always have 1 "1" result, and then each possible result is the next odd number up.

For instance, using the d6 as an example, you have 36 possible outcomes when rolling 2d6. When you take the best result, you get:

- 1 possible 1 result

- 3 possible 2 results

- 5 possible 3 results

- 7 possible 4 results

- 9 possible 5 results

- 11 possible 6 results

Just multiply each possible result by the number of times it can occur, add them all together, and divide by the total number of results. It's still a bit cumbersome but you don't have to think through every single pairing.

2d4b1 = 3.13 vs 2.5

2d6b1 = 4.47 vs 3.5

2d8b1 = 5.81 vs 4.5

2d10b1 = 7.15 vs 5.5

2d12b1 = 8.49 vs 6.5

Kane0

2019-09-25, 09:11 PM

It looks like there is a pattern, that might make it easier: you always have 1 "1" result, and then each possible result is the next odd number up.

2d4b1 = 3.13 vs 2.5

2d6b1 = 4.47 vs 3.5

2d8b1 = 5.81 vs 4.5

2d10b1 = 7.15 vs 5.5

2d12b1 = 8.49 vs 6.5

Ah yep plugging that in that's what I got, thanks!

Jay R

2019-09-25, 09:47 PM

I won't write a proof in this format, but I get the best of two n-sided dice to be:

(4n - 1) (n + 1) / 6n

That yields the following results:

n Avg (best of 2 n-sided dice)

1 1

2 1.75

3 2.444444444

4 3.125

5 3.8

6 4.472222222

7 5.142857143

8 5.8125

9 6.481481481

10 7.15

11 7.818181818

12 8.486111111

13 9.153846154

14 9.821428571

15 10.48888889

16 11.15625

17 11.82352941

18 12.49074074

19 13.15789474

20 13.825

This is equivalent to (2/3) n + 1/2 - 1/(6n)

Just as the average of a single n-sided die is n/2 + 1/2, the average of the best of two n-sided die approximates (2/3)n + 1/2.

I therefore suspect that the average of the best of three n-sided dice will approximate (3/4) n + 1/2, but I have no intention of trying to test that tonight.

Pallas

2019-09-26, 02:03 AM

Before attacking the problem, let's lay down some definitions:

Let x be the value of the higher of two dice rolls.

Let P(x) denote the probability that the higher roll has value x.

Let P(x<=k) denote the probability that x is no more than k.

Let n be the number of faces on the dies.

P(x<=n) = 1 [all rolls are less than n, obviously]

P(x<=k) = (k/n)^2 [large of two rolls is no more than k if and only if both rolls are no more than k. The outcome on each dice is independent of each other, so the probability that both dies roll under is the product of the probabilities each dice rolls under]

P(k) = P(x<=k)-P(x<=k-1) [If we start out with the cases where x is no more than k and eliminate the cases where x is no more than k-1, only the cases where x is exactly k remain]

Combining the two previous equations, we get:

P(k) = P(x<=k)-(P(x<=k-1) = (k/n)^2-((k-1)/n)^2

There's a few different ways of writing this, the simplest of which is probably (2k-1)/n^2. This expression doesn't hold up as well when you want to throw in more dies, however.

Example: Let n=6 and k=5. Then P(k)=(5/6)^2-(4/6)^2 = (25-16)/6^2 = 9/36=1/4

Example: P(1) = P(x<=1)-P(x<=0) = (1/n)^2-0=(1/n)^2 [remark: x<=0 is not a feasible outcome, so the probability of that happening is 0]

The expected value of x is given by the sum of k*P(k), for k=1,2,...,n. Starting with the simpler representation of P(k) and with a bit of algebra, we get:

sum(k*P(k)) = sum(k*(2k-1)/n^2) = (1/n^2)*sum(k*(2k-1)) = (1/n^2)*sum(2k^2-k)

Ignoring the (1/n^2) term for the moment, we get:

sum(2k^2-k) =2*sum(k^2)-sum(k).

We have closed-form formulas for computing both sum(k^2) and sum(k):

sum(k^2) = n*(n+1)*(2n+1)/6

sum(k) = n*(n+1)/2

therefore, 2*sum(k^2)-sum(k) = ((4n^3+6n^2+2n) - (3n^2+3n)) / 6 = (4n^3 + 3n^2 - n) / 6

Factoring the 1/n^2 term back in, we get:

(4n^3 + 3n^2 - n) / (6n^2) = (4n^2 + 3n - 1) / (6n)

Example: in the case of d6, we get (4*36+3*6-1)/(36) = 161/36. I've tested this scenario with a simulation in R and it checked out.

Note that the formula for P(k), (k/n)^2-((k-1)/n)^2, is easily generalized to an arbitrary number of dies. Just replace 2 with however many dies you are taking the highest of. Getting an exact formula can be challenging when there are many dies (use a spreadsheet instead!).

Coventry

2019-09-26, 08:29 PM

There is an interesting quirk to think about when using the best of 2dX dice rolling method - there is more than one kind of average.

Jay R has already given the average values for each of the die types from 1 to 20. That is the "mean" ... using the d20, across 400 rolls, you would expect an average of 13.825.

However, those rolls are really unbalanced. You will only see a result of "1" one time in 400, while you will see a result of "20" 39 times in 400 ... nearly 10% of the time.

The "median" is the mid-point when you line all the possible results up in order.

For a d3, the results are : 1,2,2,2,3,3,3,3,3

For a d4: 1,2,2,2,3,3,3,3,3,4,4,4,4,4,4,4

For a d20, that median number is near the start of the run of 15s: ...14,15,15,15,15,15,15,15...

The chart for the median is:

d2: 2

d3: 3

d4: 3

d6: 5

d8: 6

d10: 8

d12: 9

d20: 15

Deatch

2019-09-27, 05:40 AM

If I can reroll one die on a damage roll, what does that make the average damage?

So for example every attack deals +1d4 damage and I get to reroll the +1d4, taking the best of the two rolls. Instead of an average +2.5 damage per hit what does it become?

Ideally I'd like to know for d4, d6, d8, d10 and d12, i'm having a terrible math day.

It seems to me many of the responses here are for the `roll 2, pick the highest' method. This, however, is not what the OP is asking for (if i missed any reply, my apologies). The question is about reroll, which is something you need to choose to do.

In this case, the answer is this:

For the N sided die (where N is even), the average roll is (N+1)/2.

The reroll makes sense, when the roll is below this average, basically N/2 and lower.

The total average is then the average of:

(N+1)/2.............. (the average of the new roll, if you roll below N/2)

(N/2+1 + N)/2 .... (the average of the above N/2 roll)

which is

(5N+4)/8

EGplay

2019-09-27, 07:08 AM

There is an interesting quirk to think about when using the best of 2dX dice rolling method - there is more than one kind of average.

Jay R has already given the average values for each of the die types from 1 to 20. That is the "mean" ... using the d20, across 400 rolls, you would expect an average of 13.825.

However, those rolls are really unbalanced. You will only see a result of "1" one time in 400, while you will see a result of "20" 39 times in 400 ... nearly 10% of the time.

The "median" is the mid-point when you line all the possible results up in order.

For a d3, the results are : 1,2,2,2,3,3,3,3,3

For a d4: 1,2,2,2,3,3,3,3,3,4,4,4,4,4,4,4

For a d20, that median number is near the start of the run of 15s: ...14,15,15,15,15,15,15,15...

The chart for the median is:

d2: 2

d3: 3

d4: 3

d6: 5

d8: 6

d10: 8

d12: 9

d20: 15

Bolded by me: I think you'll find Jay R already accounted for this.

Also, I don't think median is very useful for OP's question.

With damage rolls, you want expectable damage over X times, for which the given averages work better.

It seems to me many of the responses here are for the `roll 2, pick the highest' method. This, however, is not what the OP is asking for (if i missed any reply, my apologies). The question is about reroll, which is something you need to choose to do.

In this case, the answer is this:

For the N sided die (where N is even), the average roll is (N+1)/2.

The reroll makes sense, when the roll is below this average, basically N/2 and lower.

The total average is then the average of:

(N+1)/2.............. (the average of the new roll, if you roll below N/2)

(N/2+1 + N)/2 .... (the average of the above N/2 roll)

which is

(5N+4)/8

I mean, you're not wrong, but OP did specify they get to use the best roll.

In that case, you'd re-roll 3's as well, and 4's operate the same as in the calculations above.

Composer99

2019-09-27, 07:39 AM

If I can reroll one die on a damage roll, what does that make the average damage?

So for example every attack deals +1d4 damage and I get to reroll the +1d4, taking the best of the two rolls. Instead of an average +2.5 damage per hit what does it become?

Ideally I'd like to know for d4, d6, d8, d10 and d12, i'm having a terrible math day.

It seems to me many of the responses here are for the `roll 2, pick the highest' method. This, however, is not what the OP is asking for (if i missed any reply, my apologies). The question is about reroll, which is something you need to choose to do.

In this case, the answer is this:

For the N sided die (where N is even), the average roll is (N+1)/2.

The reroll makes sense, when the roll is below this average, basically N/2 and lower.

The total average is then the average of:

(N+1)/2.............. (the average of the new roll, if you roll below N/2)

(N/2+1 + N)/2 .... (the average of the above N/2 roll)

which is

(5N+4)/8

The way Kane0 described it:

"I get to reroll the +1d4, taking the best of the two rolls" [emphasis mine]

The most reasonable parsing of that statement is roll two dice and drop the lowest/take the highest, as far as I can see.

If you rerolled and had to take the second roll, then the situation would be closer to what you are describing.

Edit: Swordsage'd.

NNescio

2019-09-27, 12:50 PM

Before attacking the problem, let's lay down some definitions:

Let x be the value of the higher of two dice rolls.

Let P(x) denote the probability that the higher roll has value x.

Let P(x<=k) denote the probability that x is no more than k.

Let n be the number of faces on the dies.

P(x<=n) = 1 [all rolls are less than n, obviously]

P(x<=k) = (k/n)^2 [large of two rolls is no more than k if and only if both rolls are no more than k. The outcome on each dice is independent of each other, so the probability that both dies roll under is the product of the probabilities each dice rolls under]

P(k) = P(x<=k)-P(x<=k-1) [If we start out with the cases where x is no more than k and eliminate the cases where x is no more than k-1, only the cases where x is exactly k remain]

Combining the two previous equations, we get:

P(k) = P(x<=k)-(P(x<=k-1) = (k/n)^2-((k-1)/n)^2

There's a few different ways of writing this, the simplest of which is probably (2k-1)/n^2. This expression doesn't hold up as well when you want to throw in more dies, however.

Example: Let n=6 and k=5. Then P(k)=(5/6)^2-(4/6)^2 = (25-16)/6^2 = 9/36=1/4

Example: P(1) = P(x<=1)-P(x<=0) = (1/n)^2-0=(1/n)^2 [remark: x<=0 is not a feasible outcome, so the probability of that happening is 0]

The expected value of x is given by the sum of k*P(k), for k=1,2,...,n. Starting with the simpler representation of P(k) and with a bit of algebra, we get:

sum(k*P(k)) = sum(k*(2k-1)/n^2) = (1/n^2)*sum(k*(2k-1)) = (1/n^2)*sum(2k^2-k)

Ignoring the (1/n^2) term for the moment, we get:

sum(2k^2-k) =2*sum(k^2)-sum(k).

We have closed-form formulas for computing both sum(k^2) and sum(k):

sum(k^2) = n*(n+1)*(2n+1)/6

sum(k) = n*(n+1)/2

therefore, 2*sum(k^2)-sum(k) = ((4n^3+6n^2+2n) - (3n^2+3n)) / 6 = (4n^3 + 3n^2 - n) / 6

Factoring the 1/n^2 term back in, we get:

(4n^3 + 3n^2 - n) / (6n^2) = (4n^2 + 3n - 1) / (6n)

Example: in the case of d6, we get (4*36+3*6-1)/(36) = 161/36. I've tested this scenario with a simulation in R and it checked out.

Note that the formula for P(k), (k/n)^2-((k-1)/n)^2, is easily generalized to an arbitrary number of dies. Just replace 2 with however many dies you are taking the highest of. Getting an exact formula can be challenging when there are many dies (use a spreadsheet instead!).

For an exact formula, one can use Bernoulli numbers and binomial coefficients (and the Kronecker delta), ala Faulhaber's formula. It's basically a power sum plus another term.

(Or be really cheeky and just write it as a generalized harmonic number.)

(Edit: Wait, the double series form also works, and is easier to understand and compute. It's no longer closed form though.)

Also one can derive the formula for the general case of "nDs drop lowest" in an easier way by calculating A*E(Ds) - E(min(Ds_1, Ds_2, ... Ds_A)). No need to figure out the actual distribution; just exploit Linearity of Expectation.

Edit:

I won't write a proof in this format, but I get the best of two n-sided dice to be:

(4n - 1) (n + 1) / 6n

(...)

The general formula for the expected value of the maximum roll for n s-sided dice is given by:

E(max(nDs)) = s - s^-n * sum_(i=1)^(s-1) i^n

Or without the pseudo-LaTex:

E(max(nDs)) = s - (1^n +2^n + ... + (s-1)^n)/s^n

Which is the case of n=2 simplifies to:

E(max(2Ds)) = s - (1^2 + 2^2 + ... + (s - 1)^2)/s^2

= s - (s - 1)(s)(2s - 1)/6s^2 {sum of squares

= (4s^2 + 3s - 1)/6s

= (4s - 1) (s + 1)/6s

Exactly the same as your quoted formula (just swap the s's for n's.)

Just as the average of a single n-sided die is n/2 + 1/2, the average of the best of two n-sided die approximates (2/3)n + 1/2.

I therefore suspect that the average of the best of three n-sided dice will approximate (3/4) n + 1/2, but I have no intention of trying to test that tonight.

For the case of n=3 (three dice):

E(max(3Ds)) = s - (1^3 + 2^3 + ... + (s - 1)^3)/s^3

= s - (s - 1)^2 * (s)^2/4s^3 {sum of cubes

= (s^3 + 2s - 1)/4s

= (3s - 1)(s + 1)/4s

...Which kinda approximates (3/4)*s + 1/2, yes, as your intuition predicted. But the extra term (which is ignored in the approximation) is more significant.

Edit2:

In particular, note that:

E(max(nDs)) = s - (1^n +2^n + ... + (s-1)^n)/s^n

The summation term on the right has a 'closed form' (i.e. without any summation terms) that can be computed using a variety of methods (Faulhaber's formula is the specific one, but you can just use double series and simplify it). Regardless, if you fully expand the 'closed form', it will always have the form of:

(1^n +2^n + ... + (s-1)^n) = s^(n+1)/(n + 1) - s^(n+1)/2 + ...

Note the first two terms. Taking only these first two terms:

E(max(nDs)) ≈ s - (s^(n+1)/(n + 1) - s^n/2)/s^n

= s - s/(n + 1) + 1/2

= (n/n+1)*s + 1/2

'Proving' your intuition.

Edit3:

Bolded by me: I think you'll find Jay R already accounted for this.

Also, I don't think median is very useful for OP's question.

With damage rolls, you want expectable damage over X times, for which the given averages work better.

It's also a severe abuse of terminology, as the median of a dice roll (a random distribution) and the median of a sample (a finite ordered set) are wholly different things with different definitions. (in particular a random distribution can potentially have uncountably infinite medians). It's a misguided attempt at shoehorning descriptive statistics where it doesn't belong.

That said, the median (or quartiles and percentiles) of a sum of dice rolls (drop lowest or highest) can be useful for evaluating binary outcomes, like the percent of rolls that can one shot an enemy with a certain HP.

Coventry

2019-09-27, 08:21 PM

Bolded by me: I think you'll find Jay R already accounted for this.

I used to think 13.825 was the only answer (http://www.giantitp.com/forums/showsinglepost.php?p=18949021&postcount=5), but then I changed my mind (http://www.giantitp.com/forums/showsinglepost.php?p=19033430&postcount=21).

For raw damage output per successful hit, the numerical average is correct over time.

However, if the chance to hit gets skewed by using the best of 2d20 method, then the player's average damage over time shoots way up, because there are just that many more hits landing.

Think about the skill challenge rules in 3.5. A difficult challenge, which takes 3 successful rolls of 15 or higher out of 5 is much, MUCH more difficult to achieve using a straight d20 (it is only 16.308%). The same challenge, using the best of 2d20 variant - the chance of success is a touch over 51.8745%. That extra die means increases the chance of success by more than 3 times what it had been.

Also, I don't think median is very useful for OP's question.

Maybe not. I did start off my response with "There is an interesting quirk to think about", after all.

It's also a severe abuse of terminology

For fair dice, one method of calculating the probability distribution is to simply list (and sort) the complete set of discrete possibilities. Once you have that distribution, the mean, median and mode all have well-established definitions. I believe I used the term correctly.

NNescio

2019-09-28, 03:49 AM

I used to think 13.825 was the only answer (http://www.giantitp.com/forums/showsinglepost.php?p=18949021&postcount=5), but then I changed my mind (http://www.giantitp.com/forums/showsinglepost.php?p=19033430&postcount=21).

Irrelevant. That one describes a binary outcome (hit or miss), therefore considering the median there might be useful. But OP here specifies "damage roll", not "to hit". We are calculating average damage. Not "maximum HP of target where I would have at least a 50% chance of 1HKO-ing the target." (where the median would be appropriate).

You are using the wrong measure, which answers the wrong question. It's a common fallacy in statistics and probability.

For raw damage output per successful hit, the numerical average is correct over time.

This is exactly what the OP asked.

However, if the chance to hit gets skewed by using the best of 2d20 method, then the player's average damage over time shoots way up, because there are just that many more hits landing.

Again, irrelevant. We are not considering binary outcomes.

Even if we are, you calculate the to-hit percentile (which might coincide with the median, but rarely so) for a hypothetical AC (and to hit bonus) and then multiply it by the expected damage value (on a hit) to calculate average damage (and then add in the extra crit damage or any exploding dice). This is rarely useful (because it only applies in one specific case) unless you exhaustively do the calculations for different ACs and to hit bonuses (or a to-hit roll, to abstract both as one value) and graph it out.

(Which is best done computationally instead of analytically, anyway.)

Think about the skill challenge rules in 3.5. A difficult challenge, which takes 3 successful rolls of 15 or higher out of 5 is much, MUCH more difficult to achieve using a straight d20 (it is only 16.308%). The same challenge, using the best of 2d20 variant - the chance of success is a touch over 51.8745%. That extra die means increases the chance of success by more than 3 times what it had been.

Irrelevant. that's a binary outcome. And once again nobody calculates the median unless you want to answer "Minimum amount of bonuses I need to have at least a 50% chance of succeeding at a specific DC" or "Maximum DC where I have at least a 50% chance of succeeding with a given bonus", which... is not likely not come up (most people are more interested in "what are my chances at succeeding at a specific DC for these specific bonuses").

Wrong question, wrong measure.

For fair dice, one method of calculating the probability distribution is to simply list (and sort) the complete set of discrete possibilities. Once you have that distribution, the mean, median and mode all have well-established definitions. I believe I used the term correctly.

The 'median' of a sample space (which is arbitrary depending on what question you are interested in answering) is not the same as the median of a probability distribution.

The median of a probability distribution is by definition any real number m such that P(X ≤ m) ≥ 0.5 and P(X ≥ m) ≥ 0.5. Trivially, for a d2, any real number in [1,2] (between 1 and 2, inclusive) is a median because it satisfies the above definition. Note that the number of medians here is uncountably infinite.

Powered by vBulletin® Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.