Dice probabilities question has me stumped - Page 1
Forum section: electronics / general

author: soldar
author_rank: Super Contributor
timestamp: March 17, 2024, 09:24:57 am
content: I am trying to figure out a probability question regarding a board game called Bell and Hammer which was popular a century ago and which I used to play as a kid.https://en.wikipedia.org/wiki/Bell_and_HammerIt uses eight dice and they all have all sides blank except one side which has respectively the numbers 1 to 6, a bell and a hammer, total 8 dice. So the chance of the marked side showing is 1/6The bell and the hammer are separate from the numbers so let's focus on the bell and the hammer which is simpler as there are only two dice.Probability of both showing up: 1/36Probability of only bell: 5/36Probability of only hammer: 5/36Probability of none: (5/6)^2 = 25/36Which adds up nicely to 36/36 =1With two dice I can easily make a table with all possibilities. With six dice the total is 46656 which I suppose is doable but I would like to use reasoning better than brute force.Each player throws the dice and the numbers can add up to any number between 0 and 21.The probability of getting 0 is (5/6)^6 = 0.335The probability of getting 21 is (1/6)^6 = 0.000021The probability of getting any exact combination of numbers is (1/6)^6 = 0.000021So getting a total of 1 has a probability of (1/6)^6=0.000021 because a total of 1 can only be had one way.But a total of 4 can be obtained by getting the 4 or by getting 3+1 and here I start to get lost.A 6 can be obtained by 6, by 4+2 and by 1+2+3 so getting a total of 6 is 3 times as likely as getting a 1.I get lost because I cannot get the total of probabilities to add up to 1.The probability of getting all blanks is about 1/3 so the probability of getting any number is about 2/3. This makes sense but it does not jibe with my reasoning that there are 42 combinations that produce a number out of a total possible combinations of 46656. This would indicate a chance of about 1/1000 of getting any number which is, obviously, wrong. Where am I going wrong?I was thinking of simulating this by software. One way to do it is to simulate six dice and add them up, like with physical dice, but I was thinking of just giving probabilities directly to the total and I cannot get it to work in my brain.

author: kjpye
author_rank: Contributor
timestamp: March 17, 2024, 11:00:10 am
content: Taking just one of your statements, and pointing out an error might give you something to go on...Quote from: soldar on March 17, 2024, 09:24:57 amThis is not correct; there are a large number of ways are getting a total of one. The die with the one must be in only one of the six possible positions, but the other five dice can be in any of 5 positions.Thus the correct probability is (1/6) × (5/6)^5 or .06698

author: thephil
author_rank: Regular Contributor
timestamp: March 17, 2024, 11:30:35 am
content: And here a simple way to simulate it in R (https://www.r-project.org/):First create the dice and build all possible outcomes:Code:d1 = c(NA, NA, NA, NA, NA, 1)d2 = c(NA, NA, NA, NA, NA, 2)d3 = c(NA, NA, NA, NA, NA, 3)d4 = c(NA, NA, NA, NA, NA, 4)d5 = c(NA, NA, NA, NA, NA, 5)d6 = c(NA, NA, NA, NA, NA, 6)dat = expand.grid(d1,d2,d3,d4,d5,d6)We can now get the total numbers of the different outcomes:Code:> table(apply(dat, 1, sum, na.rm=T))0 1 2 3 4 5 6 7 8 9 10 11 1215625 3125 3125 3750 3750 4375 4500 2000 1500 1625 1025 1025 42513 14 15 16 17 18 19 20 21300 200 180 55 30 30 5 5 1And compute their probabilities:Code:> table(apply(dat, 1, sum, na.rm=T)) / nrow(dat)0 1 2 3 4 53.348980e-01 6.697960e-02 6.697960e-02 8.037551e-02 8.037551e-02 9.377143e-026 7 8 9 10 119.645062e-02 4.286694e-02 3.215021e-02 3.482939e-02 2.196931e-02 2.196931e-0212 13 14 15 16 179.109225e-03 6.430041e-03 4.286694e-03 3.858025e-03 1.178841e-03 6.430041e-0418 19 20 216.430041e-04 1.071674e-04 1.071674e-04 2.143347e-05@kjpye already pointed out that the 5 blanks are distinct events, and seeing the data illustrates it nicely.Have fun playing with the numbers.

author: soldar
author_rank: Super Contributor
timestamp: March 17, 2024, 11:49:41 am
content: Quote from: kjpye on March 17, 2024, 11:00:10 amCorrect.I was also missing some combinations with numbers. There are 64 combinations which produce a result other than zero. and depending on the number of dice with numbers the probability varies.I am now convinced it is easier to simulate it the original way: "throw" the six dice with a probability of 1/6 each and then add up the result. Trying to go directly to the probability of the results is way more complicated.

author: Nominal Animal
author_rank: Super Contributor
timestamp: March 17, 2024, 11:50:00 am
content: I wrote the C code for you:Code:// SPDX-License-Identifier: CC0-1.0#include <stdlib.h>#include <stdio.h>static const unsigned char faces = {{ 1, 0, 0, 0, 0, 0 },{ 2, 0, 0, 0, 0, 0 },{ 3, 0, 0, 0, 0, 0 },{ 4, 0, 0, 0, 0, 0 },{ 5, 0, 0, 0, 0, 0 },{ 6, 0, 0, 0, 0, 0 },};int main(void){unsigned long sum = { 0 };unsigned long combos = 0;for (int d1 = 0; d1 < 6; d1++) {const int sum1 = faces;for (int d2 = 0; d2 < 6; d2++) {const int sum2 = sum1 + faces;for (int d3 = 0; d3 < 6; d3++) {const int sum3 = sum2 + faces;for (int d4 = 0; d4 < 6; d4++) {const int sum4 = sum3 + faces;for (int d5 = 0; d5 < 6; d5++) {const int sum5 = sum4 + faces;for (int d6 = 0; d6 < 6; d6++) {const int sum6 = sum5 + faces;combos++;sum++;}}}}}}for (int s = 0; s < 22; s++)printf("Sum %2d: %5lu of %lu cases (%.3f%%)\n", s, sum, combos, 100.0*sum/combos);return 0;}and it tells us the probabilities of getting each sum:Code:Sum 0: 15625 of 46656 cases (33.490%)Sum 1: 3125 of 46656 cases (6.698%)Sum 2: 3125 of 46656 cases (6.698%)Sum 3: 3750 of 46656 cases (8.038%)Sum 4: 3750 of 46656 cases (8.038%)Sum 5: 4375 of 46656 cases (9.377%)Sum 6: 4500 of 46656 cases (9.645%)Sum 7: 2000 of 46656 cases (4.287%)Sum 8: 1500 of 46656 cases (3.215%)Sum 9: 1625 of 46656 cases (3.483%)Sum 10: 1025 of 46656 cases (2.197%)Sum 11: 1025 of 46656 cases (2.197%)Sum 12: 425 of 46656 cases (0.911%)Sum 13: 300 of 46656 cases (0.643%)Sum 14: 200 of 46656 cases (0.429%)Sum 15: 180 of 46656 cases (0.386%)Sum 16: 55 of 46656 cases (0.118%)Sum 17: 30 of 46656 cases (0.064%)Sum 18: 30 of 46656 cases (0.064%)Sum 19: 5 of 46656 cases (0.011%)Sum 20: 5 of 46656 cases (0.011%)Sum 21: 1 of 46656 cases (0.002%)To get e.g. sum two, we have the following cases:Dice 2 has face 2, and all other dices have one of the empty faces; 5×1×5×5×5×5 = 3125 cases total.To get e.g. sum five, we have the following possible cases:Dice 5 has face 5, and the others have an empty face; 5×5×5×5×1×5 = 3125 cases.Dice 1 has face 1, dice 4 has face 4, and the others have an empty face; 1×5×5×5×1×5 = 625 cases.Dice 2 has face 2, dice 3 has face 3, and the others have an empty face; 5×1×1×5×5×5 = 625 cases.Since 3125+625+625 = 4375, you can have sum five in 4375 out of 46656 cases.To get sum twenty-one, there is only one case; each of the six dice needs to have their numbered face.The brute-force calculated probabilities will help you derive the algebraic form for the probability of each sum. Because the probability depends both on the number of ways the sum can be achieved using digits 1-6, each at most once, and how many terms are in each such sum, I do not believe there is a reasonable algebraic form for the probabilities.

author: soldar
author_rank: Super Contributor
timestamp: March 17, 2024, 12:03:51 pm
content: OK. Using spreadsheet I came up with these results:Code:0 = 0.3348979766803841 = 0.0669795953360772 = 0.0669795953360773 = 0.0803755144032924 = 0.0803755144032925 = 0.0937714334705086 = 0.0964506172839517 = 0.0428669410150898 = 0.0321502057613179 = 0.03482938957476010 = 0.02196930727023311 = 0.02196930727023312 = 0.00910922496570613 = 0.00643004115226314 = 0.00428669410150915 = 0.00385802469135816 = 0.00117884087791517 = 0.00064300411522618 = 0.00064300411522619 = 0.00010716735253820 = 0.00010716735253821 = 0.000021433470507Which I believe add up to 1.Yes, it is much, much easier and simpler to "roll" the dice individually and add up the numbers than to try to go directly to the end result with probabilities.

author: EPAIII
author_rank: Super Contributor
timestamp: March 18, 2024, 11:18:13 am
content: If you don't understand the odds, stay away from Vegas!They have a game called Keno. You get a card and mark a bunch of numbers on it out of a much larger number collection. But then there are variations where you have "more ways to win" by picking different patterns or combinations. Of course you pay extra for each variation that you play.So I am sitting in a casino, having my breakfast before a hard day at the convention and I decided to work out the odds. The first thing I found out was that the basic game had the WORST odds of any other game where there were published rules that allowed you to calculate them. Heaven only knows what the actual odds on the slot machines are. I thought Roulette had bad odds, but Keno's odds were much worse. So much for gut feelings.But then I started to calculate the odds with the various variations of Keno. To my immense surprise the odds got worse and worse with them. Not just worse, but MUCH worse. OK, so you can play more than one variation at a time. But still, the combined odds were still much worse even in light of the extra that you paid to play them.It was better to just play the basic game than any of the variations or any combination of the variations. And the little old ladies played and played and played. And they played multiple variations. Their money disappeared faster and faster. But on top of that, it was still the worst game there.You gotta know the odds!

author: mathsquid
author_rank: Frequent Contributor
timestamp: March 19, 2024, 11:29:31 pm
content: Quote from: soldar on March 17, 2024, 11:49:41 amYou can calculate that there are 64 ways by using a generating function. The expansion of$$(x+1) \left(x^2+1\right)\left(x^3+1\right)\left(x^4+1\right)\left(x^5+1\right)\left(x^6+1\right)$$gives you$$ x^{21}+x^{20}+x^{19}+2 x^{18}+2x^{17}+3 x^{16}+4 x^{15}+4 x^{14}+4x^{13}+5 x^{12}+5 x^{11}+5 x^{10}+5x^9+4 x^8+4 x^7+4 x^6+3 x^5+2 x^4+2x^3+x^2+x+1$$The coefficient of x^n tells the number of ways you can get n using distinct parts with size at most 6. The coefficients sum to 64 = 2^6.