Skip to Content
 

Probability 3D6 check

14 replies [Last post]
Aerjen
Offline
Joined: 08/28/2008

Hi, I'm currently working on a game where it's necessary to calculate the chances a certain number is rolled when rolling three six sided dice. If anyone's interested. The chances are listed below. Please let me know if I made any mistakes in my calculations.

3 => 0.005
4 => 0.014
5 => 0.027
6 => 0.046
7 => 0.069
8 => 0.097
9 => 0.116
10 => 0.125
11 => 0.125
12 => 0.116
13 => 0.097
14 => 0.069
15 => 0.046
16 => 0.027
17 => 0.014
18 => 0.005

Here's also a cumulative distrubution for calculating what the chances are when trying to roll equal or lower than the given number.

3 => 0.005
4 => 0.019
5 => 0.046
6 => 0.093
7 => 0.162
8 => 0.259
9 => 0.375
10 => 0.5
11 => 0.625
12 => 0.741
13 => 0.838
14 => 0.907
15 => 0.954
16 => 0.981
17 => 0.995
18 => 1

On a sidenote: would it be nice to see a seperate forum thread instead of lots of loose topics for probability questions?

EDIT: Oops, I saw I accidentally posted this in the wrong thread. I think it should be in game design. Sorry.

TrekNoid
Offline
Joined: 10/02/2009
Re: Probability 3D6 check

Aerjen wrote:
On a sidenote: would it be nice to see a seperate forum thread instead of lots of loose topics for probability questions?

I wouldn't mind a thread on all sorts of probability (card/die/etc...) ... A friend asked me last night if I could figure out a probability for him in the following scenario:

You roll 9d6, and choose the highest three numbers and add them together... What's the most likely sum?

I know how to do simple dice probability (which is why he approached me with it) but the 'choose the top three' was what made it difficult to work out...

In the end, I wrote a Perl script to roll 9d6, sort them into an array and sum the last three elements of the array... and had it run for 100,000 iterations... Doing that, I came up with:

3 occurred 0 times
4 occurred 1 times
5 occurred 0 times
6 occurred 0 times
7 occurred 28 times
8 occurred 81 times
9 occurred 232 times
10 occurred 625 times
11 occurred 1439 times
12 occurred 3052 times
13 occurred 5925 times
14 occurred 10258 times
15 occurred 15920 times
16 occurred 22478 times
17 occurred 21958 times
18 occurred 18003 times

Which isn't 'exactly' what I expected... close, but not exactly... but I've run it several times and tested it with smaller problems to verify the logic... (ie, a 3d6, choose top 2 problem)

What I'd love to know is how to calculate this with math... instead of resorting to programming (though I did enjoy the programming aspect).

TrekNoid

larienna
larienna's picture
Offline
Joined: 07/28/2008
Probability 3D6 check

If you can do computer programming, it is easy to calculate.

Instead of using the random method generation, like you did, simply generate all the possible rolls. There should be 6^9 possibilities, which mean : 10077696 permutations.

For each permutation, totalise the 3 highest dices and increment the counter result array ( 3 to 18 ). You should now have the number of permutation that generate each result.

Now for each result, take (nb_permutation / 10077696) * 100 to determine the probability percentage to roll this result. Cumulate the % together if you want to determine the "roll higher than X" or "roll lower than X".

Much more easier to evaluate than my Xd6, Y dice must be >= Z.

TrekNoid
Offline
Joined: 10/02/2009
Probability 3D6 check

Larienna wrote:
If you can do computer programming, it is easy to calculate.

Instead of using the random method generation, like you did, simply generate all the possible rolls. There should be 6^9 possibilities, which mean : 10077696 permutations.

For each permutation, totalise the 3 highest dices and increment the counter result array ( 3 to 18 ). You should now have the number of permutation that generate each result.

Now for each result, take (nb_permutation / 10077696) * 100 to determine the probability percentage to roll this result. Cumulate the % together if you want to determine the "roll higher than X" or "roll lower than X".

Much more easier to evaluate than my Xd6, Y dice must be >= Z.

I started with that approach, but short of leaving the program running overnight, 10,077,696 iterations isn't an easy task to get done...

I may go that route to be certain, but it would still be cool to know a more mathematic way to do it...

Thanks,

TrekNoid

larienna
larienna's picture
Offline
Joined: 07/28/2008
Probability 3D6 check

Come on, Thats is nothing for a computer. I think I am going to test it on mine just for fun. ( I only have a 333Mhz).

Still, in perl script, it might be a bit slower than in C++. I'll try in C++ ... if have have some time.

TrekNoid
Offline
Joined: 10/02/2009
Probability 3D6 check

Larienna wrote:
Come on, Thats is nothing for a computer. I think I am going to test it on mine just for fun. ( I only have a 333Mhz).

Still, in perl script, it might be a bit slower than in C++. I'll try in C++ ... if have have some time.

Okay... you shamed me into it :)

Actually, it turns out I had a bug in the program... which is why it was never returning... fixed it, and re-ran it, and came up with the following:

For 9 dice, choosing the top 3 rolled, here's all the possibilities:

3 occurred 1 times
4 occurred 9 times
5 occurred 45 times
6 occurred 547 times
7 occurred 2340 times
8 occurred 6948 times
9 occurred 23806 times
10 occurred 63612 times
11 occurred 140049 times
12 occurred 314245 times
13 occurred 604863 times
14 occurred 1037223 times
15 occurred 1607641 times
16 occurred 2257245 times
17 occurred 2222676 times
18 occurred 1796446 times

So, 16 is the most likely roll in this scenraio...

For all you completists, here's the 9 through 3 most likely rolls:

9d6(top3): 16
8d6(top3): 16
7d6(top3): 16
6d6(top3): 15
5d6(top3): 14
4d6(top3): 13
3d6(top3): 10/11 equally likely

Thanks, Larienna :)

TrekNoid

jkopena
Offline
Joined: 12/31/1969
Probability 3D6 check

I started working it out by raw probability. I think it's pretty hairy because of the choices. Not hard, but alot to keep track of /scribble down. In a loose manner of speaking, there's a lot of branching, e.g. the second choice being a five depends on whether any 6 was rolled and whether or not there was more than one five rolled. I fell asleep at that point, but am afraid the third one will have even more. I'm going to think for a few moments at some point about whether there's a cleaner way. I'll get back to you guys.

larienna
larienna's picture
Offline
Joined: 07/28/2008
Probability 3D6 check

Damn, your are faster than me! (`_`)

I made a C++ programm that generated the probabilities from 3 to 10 dices. Here is the table of result.

http://www.bgdf.com/files/My_Uploads/Larienna/k3d6onxd.pdf

On my 333 Mhz, the process start to slow down for these probabilities.

7 Dice - 1 Sec
8 Dice - 6 Sec
9 Dice - 40 Sec
10 Dice - 4 Min 40 Sec

Then again, It is not the most optimised code. For each permutation I had to make a backup copy of the 10 dice array and I hade to sort the whole array each time. I have now realizes that I could make it by only sorting the 3 first number to save time.

GeminiWeb
Offline
Joined: 07/31/2008
Probability 3D6 check

Alternatively, you could just simulate the results. Its amazing how well simulation approximates all combinations so well, but not surprising given the underlying statistical theory.

TrekNoid
Offline
Joined: 10/02/2009
Probability 3D6 check

Larienna wrote:
Damn, your are faster than me! (`_`)

I made a C++ programm that generated the probabilities from 3 to 10 dices. Here is the table of result.

http://www.bgdf.com/files/My_Uploads/Larienna/k3d6onxd.pdf

Well, I had an unfair advantage... I already had written the die rolling and 'choose top three' routines before you heard of it :)

Nice chart though...

Of course, now my friend came back and asked me to settle some other dice-related question he was debating with another friend...

Starting to think I need to add all this to my web page!

Thanks for nudging me into doing it... it was actually kinda fun to figure out.

TrekNoid

TrekNoid
Offline
Joined: 10/02/2009
Probability 3D6 check

GeminiWeb wrote:
Alternatively, you could just simulate the results. Its amazing how well simulation approximates all combinations so well, but not surprising given the underlying statistical theory.

It's the nature of a Perl programmer to do it by brute force, though :)

Actually, I started with simulation, then switched to doing all the combinations... and my ultimate answer ended up being off by only 1 from the real answer...

TrekNoid

jpfed
Offline
Joined: 12/31/1969
Probability 3D6 check

Re: a more purely mathematical approach:

I'm not sure about 9 dice, choosing the 3 highest, but here is some thinking that might get people's thinking going:

If you have D dice and simply choose the single highest die out of those, then the distribution has the form

P(X) = k*X^(D-1)

where k is a scaling constant that makes sure all probabilities together sum to 1, X is the potential result whose probability you're interested in, and D is the number of dice you are selecting the single highest from.

So... can anyone extend this?

Aerjen
Offline
Joined: 08/28/2008
Probability 3D6 check

Larienna, I just had a look at your pdf-file with the cumulative distribution for the 3d6's and it's the same as the numbers I came up with except for one. You state that for a roll of 5 or more the chance is 98.15% whereas I thought it should be 0,981. I guess it's a fault/inaccuracy in rounding off, but is it in your calculations or in mine?

To me it seems that the exact chance is:

1 - 1/216 - 1/72 = 0,98148148148148148148

So I guess this means we are both right and it just depends on the amount of significant numbers we use. So far for my question. Well thanks for posting your pdf on dice probabilities.

larienna
larienna's picture
Offline
Joined: 07/28/2008
Probability 3D6 check

The way I coded it is that the probability for a TN is subtracted from 1 and further TN prob are substrated from this result. The rest is the probability for rolling this TN or higher. So if one TN is round up, it might remove 0.01% more to the total changing the prob slightly for the next TN. But in general it is almost the same probabilities.

larienna
larienna's picture
Offline
Joined: 07/28/2008
Probability 3D6 check

I just want to say that I have updated the probabilities table. This time there is a table that gives the probability when keeping the lowest dices. You can find this table at the same place :

http://www.bgdf.com/files/My_Uploads/Larienna/k3d6onxd.pdf

Syndicate content


forum | by Dr. Radut