Combinatorics Counting Puzzle: Roll 20, 8-sided dice, what is the probability of getting at least 5 dice of the same value

Suppose a game in which one roll is 20, an 8-sided matrix, has a total number of possible results. To calculate the probability of a particular event, we divide the number of ways in which an event can occur by 8 ^ 20.

You can calculate the number of ways to get exactly 5 cubes of value 3. (20 select 5) gives us the number of orders 3. 7 ^ 15 gives us the number of ways we cannot get the value 3 for 15 rolls.

number of ways to get exactly 5, 3 = (20 choose 5)*7^15.

The answer can also be considered how many ways I can change the order of the rows 3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0 (20 choose 5) times the total number of values ​​equal to zero (subject to 7 legal values) 7 ^ 15 (this is correct).

  • Question 1: How can I calculate the number of ways to get exactly 5 cubes of the same value (That is, for all die values). Note: if I naively use my first answer above and multiply bt 8, do I get a huge amount of double counting?

    I understand that I could solve for each of the cases (5 1), (5, 2), (5, 3), ... (5, 8) to summarize them (the easiest way is 8 * (5 1)). Then subtract the sum of the number of overlaps (5 1) and (5 2), (5 1) and (5 3) ... (5 1) and (5, 2) and ... and (5, 8) but it seems extremely messy. I would generalize this so that it scales to a large number of samples and a large number of classes.

  • How can I calculate the number of ways to get at least 5 cubes of the same value?

    So, 111110000000000000000 or 11110100000000000002 or 11111100000001110000 or 11011211222222223333, but not 00001111222233334444 or 000511512252363347744.

I am looking for answers that either explain math or point to a library that supports this (esp python modules). Additional points for details and examples.

+3
7

/

, :

Choose(8,1)*P(one set of 5 Xs) 
- Choose(8,2)*P(a set of 5 Xs and a set of 5 Ys) 
+ Choose(8,3)*P(5 Xs, 5 Ys, 5 Zs) 
- Choose(8,4)*P(5 Xs, 5 Ys, 5 Zs, 5 As)

P(set of 5 Xs) = 20 Choose 5 * 7^15 / 8^20
P(5 Xs, 5 Ys) = 20 Choose 5,5 * 6^10 / 8^20

. " 5 ", 5,6,7,.20; , , , 10 1 5 8.

, , , ; P ( 5) = P ( 20) +... + (P ( 15) - 7 * P ( 5 )) + ((P ( 14) - 7 * P ( 5 6) - 7 * P ( 6 6)). .

+3

, -, , . , - , , .

SO .

+4

, ( ).

.

5

,

5 3 5

F (20,8,5) (5 , ) , F (20,8,5,3) (5 , 3) - . , F (20,8,5) = F (20,8,5,3) * 8 + (, 5 )

, F (20,8,5,3), , ? ... ...

: X1, X2, X3..., Xi, Xi = i

:

F(20,8,5)/20^8 = P(X1=5 or X2=5 or ... or X8=5, with R=20(rolls) and N=8(dice number))

P (statement) .

:

F(20,8,5,3)/20^8 = P(X3=5 and X1<>5 and ... and X8<>5, R=20, N=8) 
F(20,8,5,3)/20^8 = 1 - P(X1=5 or X2=5 or X4=5 or X5=5 or X6=5 or X7=5 or X8=5, R=15, N=7)  
F(20,8,5,3)/20^8 = 1 - F(15,7,5)/7^15

:

F(15,8,5) = F(15,7,5,1) * 7  
P(X1=5 or X2=5 or X4=5 or X5=5 or X6=5 or X7=5 or X8=5, R=15, N=7) = P(X1=5 and X2<>5 and X4<>5 and .. and X8<>5. R=15, N=7) * 7

F(15,7,5,1)/7^15 = 1 - F(10,6,5)/6^10 F(10,6,5) = F(10,6,5,2) * 6

F(10,6,5,2)/6^10 = 1 - F(5,5,5)/5^5
F(5,5,5) = F(5,5,5,4) * 5

, ... F (5,5,5,4) - 5 4 5 , , 5 . , 5 ^ 5. 1/5 ^ 5.

F (5,5,5) - 5 ( 5 ) 5 . , , 5. 5/5 ^ 5 = 1/5 ^ 4.

F (10,6,5,2) - 5 2 10 , , 5 . F (10,6,5,2) = (1-F (5,5,5)/5 ^ 5) * 6 ^ 10 = (1-1/5 ^ 4) * 6 ^ 10

... , - , . , .

, , , , 5 . , ...

+2

:

Prob_same_value(n) = Prob_same_value(n-1) * (1 - Prob_noone_rolling_that_value(N-(n-1)))
+1

...

5 , , .

15 .

, , : (8 * 8 15)/8 20

( 5 .)

+1

, x n :

P = ^ n * (n!/((n - x)! x!))

, 0 n.

, . , , . , .

  float calculateProbability(int tosses, int atLeastNumber) {
    float atLeastProbability = 0;
    float eventProbability = Math.pow( 1.0/8.0, tosses);
    int nFactorial = factorial(tosses);

    for ( i = 1; i <= atLeastNumber; i++) {
      atLeastProbability += eventProbability * (nFactorial / (factorial(tosses - i) * factorial(i) );
    }
  }
+1

Source: https://habr.com/ru/post/1713890/


All Articles