# How can I calculate the sum of 2 random dice out of a 3d6 pool in AnyDice?

With AnyDice it's pretty easy to calculate probalities for highest and lowest 2 of a 3d6 pool, namely with:

output [highest 2 of 3d6]
output [lowest 2 of 3d6]


However, this has a bias towards the highest and lowest thrown dice. What I want to calculate is the possible results, without bias. Reasoning behind this is that I want my players to control the outcome. It's not necessarily that the highest or lowest outcome are worse or better, it's simply that I want to offer them a decision. They choose two of the dice, add them together and there is a result. I want to give the luck d20 roll with result such as an encounter more meaning and mental impact ("why did you pick those dice!").

I had hoped AnyDice to have a random function, something like [random 2 of 3d6] but that doesn't exist. My hypothesis was that I could simply add the percentages of [highest 2 of 3d6] and [lowest 2 of 3d6] and divide that number by 2 (since I'm adding two probability calculations with a total of 100%).

But somehow this doesn't feel right. It doesn't include the possibility of a player picking the highest and the lowest number instead of the two highest or lowest.

I've been doing some tutorials in AnyDice and I reckon this definitely CAN be done with a function where the following would happen:

• Roll 3d6. Then also roll a d3 twice (not 2d3 as it would add up).
• If the d3 rolls are equal, reroll one until you get two unique d3 rolls.
• Then use the unique d3 rolls and take those dice from the 3d6 pool.
• Add those dice together, show results.

An approach of this chance could be that I take simply the average of a single die in the 3d6 pool and then multiply by 2, theoretically approaching all the possible results. This is incorrect as well as it includes all three dice and thus the average can go higher than the max of 2d6.

Perhaps I'm overthinking this calculation by using AnyDice. As the the dice order isn't relevant at all, I simply need to know all possible dice combinations a 3d6 pool can have. Not the sum, but the combinations. This is super simple, because every dice has 6 sides. So 3d6 has 6 * 6 * 6 = 216 total combinations, this includes repetition as I am interested in the probability of each throw. However, I again don't need all three dice. Only 2, which for the sake of calculation can be presumed to be picked randomly.

Another option I can think of in AnyDice is:

• Roll 3d6 and 1d3.
• Remove from 3d6 sequence the number in position 1d3.
• Add the remaining sequence's result and output probabilities.

Okay, long wall of text, but I am just not familiar enough with AnyDice to figure this out. Any help is greatly appreciated.

• Okay, it is more about perceived control. They choose the dice and the sum of those dice decides what's going to happen. In some small tests this gives players the feeling of more control over the situation, even though it's still largely random. It's more of a gimmick than anything else, but it got me curious about the statistics and that's when I found AnyDice. – Topple Jul 10 '19 at 10:42
• It is not 'only a gimmick'. It does not 'only change perception'. The 'mechanism of control' is the player choosing the 2 dice that they prefer. The choice is 100% relevant if there is a target value. – Graham Apr 4 '20 at 12:45
• @kviiri On the other hand the body of the question also says "They choose two of the dice, add them together and there is a result." That flatly contradicts the rest of the question. – Mark Wells Apr 4 '20 at 15:58
• @MarkWells Yet they asked how to choose two random dice, accepted an answer covering that, and commented approvingly of other answers based on that. If the question was to be re-scoped, it should've be done ages ago. – kviiri Apr 4 '20 at 16:18
• I don't believe it is a silly question. But I'm worried the OP might, considering their response of "Wow, this is now so obvious." I arrived at this question because I was looking to answer the same question the OP actually had: Where "They choose two of the dice, add them together and there is a result." The accepted solution was doubly disappointing, first in that it was wrong, second that the OP was convinced that their question had an 'obvious' answer that they had somehow missed. – Graham Apr 4 '20 at 17:48

The accepted solution disregards the core purpose of the actual question (how does user choice affect the outcome), so I had to try and figure it out...

I'm new to anydice, so I welcome corrections/suggestions. Here, if the player rolls their desired outcome on 2/3 dice, that becomes their choice, otherwise, output a random choice from the 3....

function: choice of A:n and B:n and C:n target T:n {
if A=T { result: A }
if B=T { result: B }
if C=T { result: C }
result: 1d{A, B, C}
}
function: combo of A:n and B:n and C:n target T {
result: [choice of A+B and B+C and A+C target T]
}

loop T over {1..12} {
output [combo of 1d6 and 1d6 and 1d6 target T] named "2/3d6 [T]"
}


Here, we can see the huge difference that player choice makes

Chance of getting a 7:

2d6: ~17%

(2/3)d6: ~42%

The probability that a pair of the three dice has sum '7' is $$\frac{3 \cdot 6 \cdot 4 + 3 \cdot 6}{6^3} = \frac{90}{216} = \frac{5}{12} ≈ 42/100$$ Src: https://math.stackexchange.com/questions/3283971/probability-that-2-dice-selected-from-3-rolled-dice-will-have-sum-7

• Comments are not for extended discussion; this conversation has been moved to chat. – nitsua60 Apr 4 '20 at 18:30
• Graham, this is very interesting. Thanks for your answer. In the scope of my question I converted my problem (chosing 2 out of 3 dice) into another problem (picking 2 random dice out of 3). Your response answers the first one, while the others answer the second one. I'm going to test with your AnyDice code. Thanks for your efforts. – Topple Apr 5 '20 at 13:32
• Furthermore, it confirms the feeling of control, because it is actually control over the situation. I greatly underestimated the mechanic and presented it as a gimmick. It is nice to see that it does actually have great impact on the result. – Topple Apr 5 '20 at 13:34

## The sum of 2 random dice from 3d6 is the same as just rolling 2d6

If you are rolling 3d6 and then picking 2 dice at random, the results are statistically the same as just adding 2d6. I am having trouble finding a way to explain this at all as it is just intuitive to me. The fact that you add a third die, then just discard a random one still means that you are just taking two results from 2d6 dice and adding them together. The extra step of adding a d6 to the pool then discarding one d6 does nothing (for any number of added and discarded from the pool, actually).

Naturally you can't just trust my intuition so consider this anydice program:

function: X:n choice {
if X = 1 {
result: {2,3}@3d6
}

if X = 2 {
result: {1,3}@3d6
}

if X = 3 {
result: {1,2}@3d6
}
}

output [d3 choice] named "random 2 of 3d6"
output 2d6 named "2d6"


Which gives this result:

What that choice function (called with a d3) is doing is picking randomly between 3 cases: choosing the 2 highest dice from the 3d6, choosing the 2 lowest, or choosing the highest and lowest. As you can see, the results end up being the same as just rolling 2d6.

• Wow, this is now so obvious. I focused completely on the impact of the 3rd die on the choice, while it is in fact not relevant at all from a probability aspect. It is only perceived relevant for a player. Thanks for giving the proof as well. I overthought this so hard that I completely missed the simplicity of it. Cheers! – Topple Jul 10 '19 at 11:21
• The jargon/proof version of this answer is: "No matter which die you remove, you are still convolving two density functions of 1d6 into a single density of 2d6. The result is always the same and the player choice is completely illusory." +1 for communicating this without jargon. – Novak Jul 11 '19 at 2:26
• Well, the third dice might be relevant to the probability since it's player choice, not random choice. If the players can see the numbers rolled on 3d6 and pick 2 of them, that isn't really well modelled by picking a random 2 of 3d6 if they have any reason to prefer particular outcomes (regardless of whether those outcomes are actually better). If they think they want high numbers then it'll be equivalent to [highest 2 of 3d6]. If they want a particular number (or range) then that will have a significantly higher probability than it does in a regular 2d6 distribution. – Ben Jul 11 '19 at 4:07
• @Ben yes, this is my expectation of the roll 3 pick 2 mechanic. However, it is incredibly difficult to predict what players want to do. A specific range could be implemented in an AnyDice function, however it goes a bit outside of the scope of my question. Would be interesting though. – Topple Jul 11 '19 at 8:51
• Ben+1 The Solution: "The sum of 2 random dice from 3d6..." Is completely counter to the question: "They choose two of the dice..." Presumably their choice is not random. Chance of rolling a given number with 2 d6s and no choice: output 2d6 Chance of being able to choose a given number from any combination of 2/3 d6s: ??? (not the same) The key difference is the total number of outcomes. Rolling 2d6 you only get one result. Rolling 3d6 and choosing 2, you get 3 potentially different results, from which the user has a choice. The whole point the OP was going for it missed. – Graham Apr 4 '20 at 12:06

## Two random dice from 3d6 is the same as 2d6

No matter how many dice you roll, each die roll is stochastically independent. This means none of the individual dice alters the probability distribution of the outcome of any other die in any way, and it follows that rolling dice that are simply ignored in the final result can simply be not rolled at all. Intuitively, you could give the player the choice before rolling and the result wouldn't be changed at all.

For a simpler example case, consider that you want the distribution of a random 1d6 from 2d6 (so one die less rolled, and one die less in result). Let's call the dice $$\R\$$ and $$\G\$$ for red and green respectively, and assume they're identical otherwise. This is what the usual distribution of the 2d6 would look like:

$$\ \begin{array}{|c|c|c|c|c|c|c|} \hline & \textbf{G=1} & \textbf{G=2} & \textbf{G=3} & \textbf{G=4} & \textbf{G=5} & \textbf{G=6} \\ \hline \textbf{R=1} & {2} & {3} & {4} & {5} & {6} & {7}\\ \hline \textbf{R=2} & {3} & {4} & {5} & {6} & {7} & {8}\\ \hline \textbf{R=3} & {4} & {5} & {6} & {7} & {8} & {9}\\ \hline \textbf{R=4} & {5} & {6} & {7} & {8} & {9} & {10}\\ \hline \textbf{R=5} & {6} & {7} & {8} & {9} & {10} & {11}\\ \hline \textbf{R=6} & {7} & {8} & {9} & {10} & {11} & {12}\\ \hline \end{array} \$$

Each cell has an equal probability: 1/36. If we ignore one of the dice, say $$\G\$$, it'll look like this:

$$\ \begin{array}{|c|c|c|c|c|c|c|} \hline & \textbf{G=1} & \textbf{G=2} & \textbf{G=3} & \textbf{G=4} & \textbf{G=5} & \textbf{G=6} \\ \hline \textbf{R=1} & {1} & {1} & {1} & {1} & {1} & {1}\\ \hline \textbf{R=2} & {2} & {2} & {2} & {2} & {2} & {2}\\ \hline \textbf{R=3} & {3} & {3} & {3} & {3} & {3} & {3}\\ \hline \textbf{R=4} & {4} & {4} & {4} & {4} & {4} & {4}\\ \hline \textbf{R=5} & {5} & {5} & {5} & {5} & {5} & {5}\\ \hline \textbf{R=6} & {6} & {6} & {6} & {6} & {6} & {6}\\ \hline \end{array} \$$

Each cell still has a 1/36 probability, but there are now only six distinct outcomes, each with a total probability of 1/6. The $$\G\$$ die doesn't matter anymore and we might as well have not rolled it at all. The reverse case where we omit $$\R\$$ from the result is identical; swap the labels of the second array if you don't believe me! You can construct a similar, three dimensional grid to assure yourself that this remains true in the "3d6, pick two at random" case.

• Thank you for your answer and some more in-depth literature. – Topple Jul 11 '19 at 8:51

I don't know much about AnyDice, but here's how I would

## Calculate this in Python

from collections import defaultdict as dd

result = dd(int)
for x in range(1,7):
for y in range(1,7):
for z in range(1,7):
a,b,c = sorted((x,y,z))
result[a+b, a+c, b+c] += 1

accum = dd(int)
for key,value in result.items():
for a in set(key):
accum[a]+=value

for k in sorted(accum.keys()):
print(k, accum[k], accum[k]/216)

for k in sorted(result.keys()):
print(k, result[k], result[k]/216)


Which (with some formatting) gives the below tables. The first lists the number of times each value is an option (that is, rolling three 1s gives you the option to choose 2 once, not three times). The probability column doesn't sum to 1 because of the inherent overlap caused by the choice you give the players.

The second, much longer, table lists the choice of three options first, then how many times it shows up, then its ultimate probability.

$$\ \begin{array}{|c|c|c|} \hline \textbf{Value} & \textbf{Is an option N times} & \textbf{Probability} \\ \hline 2 & 16 & 0.07407407407407407 \\ \hline 3 & 30 & 0.1388888888888889 \\ \hline 4 & 46 & 0.21296296296296297 \\ \hline 5 & 60 & 0.2777777777777778 \\ \hline 6 & 76 & 0.35185185185185186 \\ \hline 7 & 90 & 0.4166666666666667 \\ \hline 8 & 76 & 0.35185185185185186 \\ \hline 9 & 60 & 0.2777777777777778 \\ \hline 10 & 46 & 0.21296296296296297 \\ \hline 11 & 30 & 0.1388888888888889 \\ \hline 12 & 16 & 0.07407407407407407 \\ \hline \end{array} \$$

$$\ \begin{array}{|c|c|c|} \hline \textbf{Options} & \textbf{Count} & \textbf{Probability} \\ \hline (2, 2, 2) & 1 & 0.004629629629629629 \\ \hline (2, 3, 3) & 3 & 0.013888888888888888 \\ \hline (2, 4, 4) & 3 & 0.013888888888888888 \\ \hline (2, 5, 5) & 3 & 0.013888888888888888 \\ \hline (2, 6, 6) & 3 & 0.013888888888888888 \\ \hline (2, 7, 7) & 3 & 0.013888888888888888 \\ \hline (3, 3, 4) & 3 & 0.013888888888888888 \\ \hline (3, 4, 5) & 6 & 0.027777777777777776 \\ \hline (3, 5, 6) & 6 & 0.027777777777777776 \\ \hline (3, 6, 7) & 6 & 0.027777777777777776 \\ \hline (3, 7, 8) & 6 & 0.027777777777777776 \\ \hline (4, 4, 4) & 1 & 0.004629629629629629 \\ \hline (4, 4, 6) & 3 & 0.013888888888888888 \\ \hline (4, 5, 5) & 3 & 0.013888888888888888 \\ \hline (4, 5, 7) & 6 & 0.027777777777777776 \\ \hline (4, 6, 6) & 3 & 0.013888888888888888 \\ \hline (4, 6, 8) & 6 & 0.027777777777777776 \\ \hline (4, 7, 7) & 3 & 0.013888888888888888 \\ \hline (4, 7, 9) & 6 & 0.027777777777777776 \\ \hline (4, 8, 8) & 3 & 0.013888888888888888 \\ \hline (5, 5, 6) & 3 & 0.013888888888888888 \\ \hline (5, 5, 8) & 3 & 0.013888888888888888 \\ \hline (5, 6, 7) & 6 & 0.027777777777777776 \\ \hline (5, 6, 9) & 6 & 0.027777777777777776 \\ \hline (5, 7, 8) & 6 & 0.027777777777777776 \\ \hline (5, 7, 10) & 6 & 0.027777777777777776 \\ \hline (5, 8, 9) & 6 & 0.027777777777777776 \\ \hline (6, 6, 6) & 1 & 0.004629629629629629 \\ \hline (6, 6, 8) & 3 & 0.013888888888888888 \\ \hline (6, 6, 10) & 3 & 0.013888888888888888 \\ \hline (6, 7, 7) & 3 & 0.013888888888888888 \\ \hline (6, 7, 9) & 6 & 0.027777777777777776 \\ \hline (6, 7, 11) & 6 & 0.027777777777777776 \\ \hline (6, 8, 8) & 3 & 0.013888888888888888 \\ \hline (6, 8, 10) & 6 & 0.027777777777777776 \\ \hline (6, 9, 9) & 3 & 0.013888888888888888 \\ \hline (7, 7, 8) & 3 & 0.013888888888888888 \\ \hline (7, 7, 10) & 3 & 0.013888888888888888 \\ \hline (7, 7, 12) & 3 & 0.013888888888888888 \\ \hline (7, 8, 9) & 6 & 0.027777777777777776 \\ \hline (7, 8, 11) & 6 & 0.027777777777777776 \\ \hline (7, 9, 10) & 6 & 0.027777777777777776 \\ \hline (8, 8, 8) & 1 & 0.004629629629629629 \\ \hline (8, 8, 10) & 3 & 0.013888888888888888 \\ \hline (8, 8, 12) & 3 & 0.013888888888888888 \\ \hline (8, 9, 9) & 3 & 0.013888888888888888 \\ \hline (8, 9, 11) & 6 & 0.027777777777777776 \\ \hline (8, 10, 10) & 3 & 0.013888888888888888 \\ \hline (9, 9, 10) & 3 & 0.013888888888888888 \\ \hline (9, 9, 12) & 3 & 0.013888888888888888 \\ \hline (9, 10, 11) & 6 & 0.027777777777777776 \\ \hline (10, 10, 10) & 1 & 0.004629629629629629 \\ \hline (10, 10, 12) & 3 & 0.013888888888888888 \\ \hline (10, 11, 11) & 3 & 0.013888888888888888 \\ \hline (11, 11, 12) & 3 & 0.013888888888888888 \\ \hline (12, 12, 12) & 1 & 0.004629629629629629 \\ \hline \end{array} \$$

• Always nice to have some Python creep in, thanks. – Topple Jul 11 '19 at 8:52
• This accomplishes the correct outcome, showing that the choice of 2 out of 3 dice is not the same as simply rolling 2 dice. Cheers! – Graham Apr 4 '20 at 12:50