3
\$\begingroup\$

I have a very similar question to Using AnyDice to determine the odds of getting a specific number sequence on multiple dice

I want to know the odds of rolling a 1,2,3 out of 4d6. Or getting a 3 and a 4 on 2d6 vs the same 2 results out of 3d6.

\$\endgroup\$
3
\$\begingroup\$

We'll pretend we have k s-sided dice and we are trying to find the probability to get n specific different results. The first die roll we have an n/s chance of getting a number we need and an (s-n)/s chance we get a number we don't need. When we get a number we need we are looking to get n-1 numbers we need on k-1 different dice. When we get a number we don't need we are still looking to get n numbers but with k-1 dice left to roll. The probability of getting n = 0 results is always 1 regardless of the number of dice. The probability of getting any more results when there aren't any dice left (k = 0) is 0.

prob s k 0 = 1
prob s 0 n = 0
prob s k n = (n*(prob s (k-1) (n-1)) + (s-n)*(prob s (k-1) n))/s

We can make a table to calculate these for s = 6 sided dice.

  0   1        2        3       4      5 6 n
0 1   0        0        0       0      0 0
1 1   1/6      0        0       0      0 0
2 1  11/36     2/36     0       0      0 0
3 1  91/216   30/216    6/216   0      0 0 
4 1 671/1296 302/1296 108/1296 24/1296 0 0
.
.
.
k

The problems you are interested in are getting n=2 specific different results with k=2 dice which has a probability of 2/36, getting n=2 specific different results with k=3 dice, which has a probability of 30/216, and getting n=3 specific different results with k=4 dice, which has a probability of 108/1296.

There is probably a simpler non-recursive formula based on the factorial function.

We can check the above formula with counting arguments.

To get a 3 and a 4 rolling 2d6 there's 1 combination of dice that will work. We don't care if we roll the 3 first or the 4 first, so there are 2! = 2*1 = 2 orders we can roll the combination in. 2 of the 6^2 possible rolls result in a 3 and a 4. The probability of rolling a 3 and a 4 on 2d6 is 2/36 or 1/18.

We can make a table of all the ways to roll a 3 and a 4 on 2 dice and count them to make sure this is correct

3 4    1 way
4 3    1 way  
       2 ways

2 ways out of 36 roll a 3 and a 4.

There are more ways to roll a 3 and a 4 than there are ways to roll two 3s. Theres' only one way to roll two 3s. If we switch the order we roll the dice in it doesn't add another way to get two 3s. This will matter when we add extra dice.

3 3    1 way
3 3    0 ways! We already counted this.
       1 way

Let's write down all the ways we can roll a 3 and a 4 on 3d6. We'll use * to denote any result that is neither a 3 or a 4 (there are 4 possible such results: 1, 2, 5, and 6)

3 4 *    4 ways
3 4 3    1 way
3 4 4    1 way
4 3 *    4 ways
4 3 3    1 way
4 3 4    1 way
3 * 4    4 ways
3 3 4    1 way
3 4 4    0 ways! We already counted this.
4 * 3    4 ways
4 3 3    0 ways! We already counted this.
4 4 3    1 way
* 3 4    4 ways
3 3 4    0 ways! We already counted this.
4 3 4    0 ways! We already counted this.
* 4 3    4 ways
3 4 3    0 ways! We already counted this.
4 4 3    0 ways! We already counted this.
         30 ways

When one of the results isn't a 3 or 4 it's easy, there's 4 combinations that can be in 3! = 3*2*1 = 6 orders. When all of the results have a 3 or 4 then one of the numbers will be repeated. Instead of having 2 combinations that can be in 3! = 3*2*1 = 6, half of the orders are duplicates, so there are only 30=6*4+2*3 ways to roll a 3 and a 4. The probability of rolling a 3 and a 4 on 3d6 is therefore 30/6^3 or 5/36.

Counting results to check larger problems is tedious. This line of thinking is leading to a recursive formula involving factorial which is no simpler than the recursive formula we started with.

\$\endgroup\$
1
\$\begingroup\$

Cirdec has given a recursive equation to find the probability of rolling k s-sided dice and getting n specific different results. Here's a more intuitive method to get the same answers (similar to probability tree diagrams [1] [2]):

Get at least one result each of 1, 2, and 3 on 4d6 = 1/12

You have one extra die that doesn't need to be one of these numbers. I'll say that you have one die that can 'fail'.

There are then 4 different ways that we can achieved the desired result: the first roll fails and the rest succeed, the second roll fails and the rest succeed, the third roll fails and the rest succeed, or the first three rolls succeed (the 4th "fails" as there aren't any numbers left to match).

Probabilities for these scenarios are found below. For each die roll, the probability of an outcome is determined by how many numbers are left to find and how many sides are on the die. These probabilities are then multiplied to get the probability of this series of rolls. We will then add these four values to get the probability of the overall success.

  • 1st roll fails: 3/6 (1st roll fails) * 3/6 (2nd roll succeeds) * 2/6 (3rd roll succeeds) * 1/6 (4th roll succeeds) = 18/1296

  • 2nd roll fails: 3/6 (1st roll succeeds) * 4/6 (2nd roll fails) * 2/6 (3rd roll succeeds) * 1/6 (4th roll succeeds) = 24/1296

  • 3rd roll fails: 3/6 (1st roll succeeds) * 2/6 (2nd roll succeeds) * 5/6 (3rd roll fails) * 1/6 (4th roll succeeds) = 30/1296

  • All succeed: 3/6 (1st roll succeeds) * 2/6 (2nd roll succeeds) * 1/6 (3rd roll succeeds) * 6/6 (4th roll fails) = 36/1296

So the overall probability of success is (18 + 24 + 30 + 36)/1296 = 108/1296 = 1/12.

Note that our four probabilities were

  • 3/6 * (3/6 * 2/6 * 1/6)
  • 4/6 * (3/6 * 2/6 * 1/6)
  • 5/6 * (3/6 * 2/6 * 1/6)
  • 6/6 * (3/6 * 2/6 * 1/6)

This pattern will hold when we have just one extra die. It will become more complicated with extra dice.

Get at least one result each of 3 and 4 on 3d6 = 5/36

Following the same logic, we have three possible success scenarios:

  • 1st roll fails: 4/6 (1st roll fails) * 2/6 (2nd roll succeeds) * 1/6 (3rd roll succeeds) = 8/216

  • 2nd roll fails: 2/6 (1st roll succeeds) * 5/6 (2nd roll fails) * 1/6 (3rd roll succeeds) = 10/216

  • All succeed: 2/6 (1st roll succeeds) * 1/6 (2nd roll succeeds) * 6/6 (3rd roll fails) = 12/216

So the overall probability of success is (8 + 10 + 12)/216 = 30/216 = 5/36

Again, you can see the same pattern with one extra die:

  • 4/6 * (2/6 * 1/6)
  • 5/6 * (2/6 * 1/6)
  • 6/6 * (2/6 * 1/6)
\$\endgroup\$
1
\$\begingroup\$

Since you tagged this with , here's a simple AnyDice function to calculate this:

function: SUB:s in SEQ:s {
  loop N over SUB {
    if (N = SUB) > (N = SEQ) { result: 0 }
  }
  result: 1
}
output [{1,2,3} in 4d6] named "1,2,3 in 4d6"
output [{1,2,2} in 4d6] named "1,2,2 in 4d6"
output [{3,4} in 2d6] named "3,4 in 2d6"
output [{3,4} in 3d6] named "3,4 in 3d6"

The function [SUB in SEQ] takes two sequences, and returns 1 if the first is a subset of the second, and 0 otherwise. When applied to dice, it therefore returns a biased die expressing the probability that the first die roll (or fixed sequence, as in the examples above) is a subset of the second.

\$\endgroup\$
-1
\$\begingroup\$

Four possible successful outcomes.

First die success chance is \$\frac{3}{6}\$, or \$\frac{1}{2}\$. 1, 2 or a 3.

Second die success chance is \$\frac{2}{6}\$, or \$\frac{1}{2}\$. Whichever two are left.

Last die success chance is \$\frac{1}{6}\$. Whatever the last one is.

First 3 die succeed. \$\frac{1}{2} \times \frac{1}{3} \times \frac{1}{6} \times\$ (\$\frac{6}{6}\$, Do not care)

First die fails. \$\frac{1}{2} \times (\frac{1}{2} \times \frac{1}{3} \times \frac{1}{6})\$

Second die fails. \$\frac{1}{2} \times \frac{2}{3} \times \frac{1}{3} \times \frac{1}{6}\$. \$\frac{2}{3}\$ is the chance you don't get a success.

Third die fails. \$\frac{1}{2} \times \frac{1}{3} \times \frac{5}{6} \times \frac{1}{6}\$. \$\frac{5}{6}\$ is the chance you don't get a success.

Sum: \$\frac{1}{36} + \frac{1}{72} + \frac{2}{108} + \frac{5}{216} = \frac{5}{216} + \frac{4}{216} + \frac{3}{216} + \frac{6}{216}= \frac{18}{218} = \frac{1}{12}\$

3 and a 4 out of 2d6 will be \$\frac{2}{6} \times \frac{1}{6} = \frac{2}{36} = \frac{1}{18}\$

1, 2, and 3 with a 3d6 is a \$\frac{1}{2} \times \frac{1}{3} \times \frac{1}{6} = \frac{1}{36}\$

3 and a 4 out of 3d6 = \$\frac{1}{3} \times \frac{1}{6} \times \frac{6}{6} + \frac{1}{3} \times \frac{5}{6} \times \frac{1}{6} + \frac{2}{3} \times \frac{1}{3} \times \frac{1}{6} = \frac{1}{18} + \frac{5}{108} + \frac{2}{54} = \frac{6}{108} + \frac{5}{106} + \frac{4}{108} = \frac{15}{108} = \frac{5}{36}\$

\$\endgroup\$
  • \$\begingroup\$ It looks like you're trying to give the same answer I already gave. Is there something you're adding? \$\endgroup\$ – DCShannon Aug 31 '15 at 1:46
-2
\$\begingroup\$

rolling a 1,2,3 out of 4d6

You want 3 particular values (it does not matter what they are) on 4 dice: you need 3 dice to carry those values - the other one doesn't matter. Imagine lining the dice up in order - 3 are set ((3x2x1)=5 in 216 chance) and the other dice can be in any of the 4 positions so (4x5)=20 in 216 or 5 in 54.

getting a 3 and a 4 on 2d6 vs the same 2 results out of 3d6

Again, 2 particular values. On 2 dice (2x1)=2 in 36; on 3 dice (3x2)=6 in 36 or 1 in 6.

\$\endgroup\$
  • \$\begingroup\$ This doesn't look right. 1/36 would be the probability of rolling (say) a 3 and a 4 on 2d6 in that order. But the OP seems to be asking for the probability of getting those two dice in any order, which is twice that. And I don't think your other calculations are right, either; besides the ordering issue, you're also double-counting some rolls (because, for example, a roll of 1,2,2,3 can match a subsequence of 1,2,3 in two ways; either as 1,2,*,3 or as 1,*,2,3). \$\endgroup\$ – Ilmari Karonen Jul 29 '15 at 23:01
  • \$\begingroup\$ This is all wrong. It's possible it may make sense given a misreading of the question, but the logic is described vaguely enough I can't tell for sure. No idea how (3x2x1) = 5/216. \$\endgroup\$ – DCShannon Aug 31 '15 at 1:43
-3
\$\begingroup\$

Ah... Probability. In probability, each die is treated independently of the other dice. That is to say, rolling a 1 on one die has no bearing on what the other dice roll. Knowing this, what is the probability of rolling a 1 on a d4? 1/4 or 25%. What is the probability of rolling all 1's? Simply multiply the probabilities, so getting all 1's on 3d4 becomes 1/4 x 1/4 x 1/4 = 1/64.

Now you want to roll a 1, a 2 and a 3 of 3d4. The total of possible combinations is 4 x 4 x 4 = 64. Looking at the sample set, we find:

(1,1,1) (1,2,1) (1,3,1) (1,4,1)
(1,1,2) (1,2,2) (1,3,2) (1,4,2)
(1,1,3) (1,2,3) (1,3,3) (1,4,3)
(1,1,4) (1,2,4) (1,3,4) (1,4,4)
(2,1,1) (2,2,1) (2,3,1) (2,4,1)
(2,1,2) (2,2,2) (2,3,2) (1,4,2)
(2,1,3) (2,2,3) (2,3,3) (2,4,3)
(2,1,4) (2,2,4) (2,3,4) (2,4,4)
(3,1,1) (3,2,1) (3,3,1) (3,4,1)
(3,1,2) (3,2,2) (3,3,2) (3,4,2)
(3,1,3) (3,2,3) (3,3,3) (3,4,3)
(3,1,4) (3,2,4) (3,3,4) (3,4,4)
(4,1,1) (4,2,1) (4,3,1) (4,4,1)
(4,1,2) (4,2,2) (4,3,2) (4,4,2)
(4,1,3) (4,2,3) (4,3,3) (4,4,3)
(4,1,4) (4,2,4) (4,3,4) (4,4,4)

Now, how many (1,2,3), in any order are there? 6. This gives up a probability of 6/64 or 3/32. As a short cut, we can assume that we have a 3/4 of getting one of the numbers on a toss, 1/2 of getting one of the remaining numbers on a toss and 1/4 of the last number and multiply the those probabilities. 3/4 × 1/2 × 1/4 = 3/32.

You can apply the same logic to d6, d8 or any other dice in your bag.

\$\endgroup\$
  • 3
    \$\begingroup\$ This doesn't answer the question. It's a high quality and accurate treatment of dice probabilities, but you don't mention the case that the querent is asking about: how do you calculate the probablility of rolling a certain set of numbers when you roll more dice than there are numbers in the set? You show how to calculate (1,2,3) out of 3d4, but the querent is asking about (1,2,3,X) out of 4d4. \$\endgroup\$ – DuckTapeAl Apr 21 '15 at 18:19
  • \$\begingroup\$ This logic doesn't work when applied to extra dice. If you are rolling 3d4 looking for a 1 and a 2 there's a 2/4 chance you get a number you are looking for on the first die, a 1/4 chance you get a number you are looking for on the second die, and a 1/1 chance you get a number you are looking for on the third die. But the probability isn't 1/8th. It's 18/64. \$\endgroup\$ – Cirdec Apr 21 '15 at 18:23
  • \$\begingroup\$ The table technique still works, but the shortcut at the end fails with extra dice. You have to account for the possibility of failing on one of the dice. \$\endgroup\$ – DCShannon Apr 21 '15 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.