Probability Distribution of Dice

Zander is right, what I really want is a formula for calculating the % frequency for the dice. Sorry if that wasn't clear. I can see a lot of you tried to help me, but sadly, it's not the help I need :( (heh, and I certainly don't need a dice roller. A simple $rand() function in mIRC is fine. I currently have over 800 lines of scripts for D&D related actions, so as far as rolling the dice goes, I'm fine).

I've managed to notice a lot of the facts that Zander and Drawmack have noticed too. It's fairly easy to work out the first and last value of any roll, as it is always 1/sample space. The 'middle value' is always the highest (where the middle value is sn-n where s=sides on the dice and n=number of dice rolled. I originally was only working with sets of dice with the same amount of sides (eg. 8d6), but if the formula could work for mixing dice types, that would be great too). Drawmack, I'm going to have to disagree with the part about the parabola. I've plotted some graphs, and they seem to be more bell curve shaped, rather than parabolic. Though, I have not proved this yet, so for all I really know, you could be right.

That dice program sounds interesting, Fenlock, though I haven't had a chance to run it yet, so I don't know if it is what I want. It appears to also be uncompiled, which would be perfect if I wanted to extract the formula from it.
 

log in or register to remove this ad

I made a little Matlab code that makes 4d6, drop lowest stats:

for i = 1 : 10000
for j = 1 : 4
FourRolls(j) = ceil(rand*6);
end

Stat = sum(FourRolls)-min(FourRolls);
StatResults(Stat) = StatResults(Stat) + 1;
end

That code generates 10000 stats and puts them in a vector. Now you can calculate all the frequencies by dividing the result vectors appropriate column by 10000, or whatever number of simulations you made.

Analytical results would be intresting to see, also. It just would take some more time ;)

edit: ok, I noticed this wasn't what you were looking for, my bad
 
Last edited:

Riveneye said:
Drawmack, I'm going to have to disagree with the part about the parabola.

It is a bell curve, however the formula for generating the the curve appears to be a second degree formula which means that is it a parabola regardless of shape.
 

What a wonderful project!

To summarize when we roll dice, we want to know how many ways we can get a certain sum.

IE the standard craps distribution (2d6) would look like

SUM # of Ways
---- -----------
02 1
03 2
04 3
05 4
06 5
07 6
08 5
09 4
10 3
11 2
12 1

Note the linearity, it leads us to guess the total order = (number of dice -1) and the it has a maximum at (#Dice*#Sides+#sides)/2

I will look into this some more, but I also feel that the solution will involve factorials as opposed to exponentially
 
Last edited:

I am too lazy to work out the general formula, but you can write a quick-and-dirty algorithm for getting the exact probabilities easily:

If you want n p-sided dice rolled, generate all possible outcomes (vectors of length n with entries 1..p), sum over the entries in each outcome, and count how often you get each result. Divide this count by the total number of outcome vectors to get the probability to roll exactly this number. To get the probability of rolling equal or less, add up all probabilities for rolling equal or less.

Example, using 2d6: you have 36 outcome vectors

(1,1), (1,2), ..., (6,6)

and possible results ranging from 1+1=2 to 6+6=12. If you count how often you get each result, you get

2 x1, 3 x2, ..., 7 x6, 8 x5, ..., 11 x2, 12 x1.

As you started with 36 outcome vectors with equal probability, your chance to roll 2 is 1/36, to roll 3 is 2/36, etc. Resulting in

1/36 to roll 2 or less
(1+2)/36 to roll 3 or less
...
(1+2+3+4+5+6)/36 to roll 7 or less
(1+2+3+4+5+6+5)/36 to roll 8 or less
...
(1+2+3+4+5+6+5+4+3+2+1)/36 to roll 12 or less

Note that the last is really 36/36 or 100 %.

You can easily generalize this method to more dice of different types.
 

This is a great question! I've wondered too about an analytical formula for determining the probability of achieving one outcome from throwing some set of dice. I couldn't figure it out. The issue to which I wanted to apply this idea was D&D weapon damage calculations. Determining the average weapon damage in combat is not as simple as averaging the damage roll when you fight creatures with damage reduction--you actually need the discreet probability distribution of the damage roll (and critical hit damage roll). Since there are only a small number of combinations of rolls you need to make for all D&D weapons: 1d4, 2d4, 3d4, 4d4, 6d4, 8d4, 1d6, 2d6, etc.,
I went ahead and counted all the ways of rolling outcomes for each dice combo, using a little help from Excel and recognizing patterns. It was still a pain in the ass.

Here's an example, for 4d6.

oc___#ways___probability

4_____1______0.000771604938271605
5_____4______0.00308641975308642
6_____10_____0.00771604938271605
7_____20_____0.0154320987654321
8_____35_____0.0270061728395062
9_____56_____0.0432098765432099
10____80_____0.0617283950617284
11____104____0.0802469135802469
12____125____0.0964506172839506
13____140____0.108024691358025
14____146____0.112654320987654
15____140____0.108024691358025
16____125____0.0964506172839506
17____104____0.0802469135802469
18____80_____0.0617283950617284
19____56_____0.0432098765432099
20____35_____0.0270061728395062
21____20_____0.0154320987654321
22____10_____0.00771604938271605
23____4______0.00308641975308642
24____1______0.000771604938271605

The rest of the roll combo distributions can be found at

http://www.geocities.com/frisbeet/DandDandFightin.html

Select the "Weapon Comparison" Excel file. Unhide the "rolls" worksheet. Hopefully this helps a little.
 

MatLab baby! Oh yeah, Numion is in the know. Nice Monte Carlo simulation, Numion. ;-)

Okay, I'm sorry to say but there is NOT a single equation to determine what you would like accurately. It really isn't all that difficult to write a code to solve your problem numerically though if it has a random number generator. Actually, if anyone has a compiler, they can write you some C code or basic or whatever. All those programming languages have random number generators. JAVA can generate random numbers, at least so a friend of mine says. mIRC might have one already in the scripts.

Patrick
 

bahh! All you CS people like programs. I don't even know how to get my PC to do that crap, and I don't wanna know (actually that last part's not true). Give me tables, like the logarithm tables of old. I mean, there is an explicit answer to these probabilities--it's not like the three-body problem or quantum mechanics, which necessitate numerical, approximate solutions. So, here's the next table:

3d12

oc__#ways__probability
3_____1______0.000578703703703704
4_____3______0.00173611111111111
5_____6______0.00347222222222222
6_____10_____0.00578703703703704
7_____15_____0.00868055555555556
8_____21_____0.0121527777777778
9_____28_____0.0162037037037037
10____36_____0.0208333333333333
11____45_____0.0260416666666667
12____55_____0.0318287037037037
13____66_____0.0381944444444444
14____78_____0.0451388888888889
15____88_____0.0509259259259259
16____96_____0.0555555555555556
17____102____0.0590277777777778
18____106____0.0613425925925926
19____108____0.0625
20____108____0.0625
21____106____0.0613425925925926
22____102____0.0590277777777778
23____96_____0.0555555555555556
24____88_____0.0509259259259259
25____78_____0.0451388888888889
26____66_____0.0381944444444444
27____55_____0.0318287037037037
28____45_____0.0260416666666667
29____36_____0.0208333333333333
30____28_____0.0162037037037037
31____21_____0.0121527777777778
32____15_____0.00868055555555556
33____10_____0.00578703703703704
34____6______0.00347222222222222
35____3______0.00173611111111111
36____1______0.000578703703703704
 

You could do it recursively. The probability of rolling 7 of 3d6 is the probability of rolling a 1 on one die times the probability of rolling 6 on 2d6, plus the probability of rolling a 2 on one die times the probability of rolling 5 on 2d6 ...

Might make for a quicker computation of very large sample spaces (frex 42d20).

PS
 

Kugar said:
SUM # of Ways
---- -----------
02 1
03 2
04 3
05 4
06 5
07 6
08 5
09 4
10 3
11 2
12 1

Note the linearity, it leads us to guess the total order = (number of dice -1) and the it has a maximum at (#Dice*#Sides+#sides)/2
s = sides
n = number of dice
p = probability
tr = total sets to this result
tc = total sets
r = result
nr = number of results


What we need it this formula coded

p = tr/tc

tc is fairly simple to calculate.
s^n

tr is the difficult part of the forumla to calculate taking only sides and number of dice as input.

Here is what we think we've got so far
Max = s + n -1

The total number of results is s * n - n
The total number of combinations is s^n

The part that I'm having trouble coming up with a formula for is the total number of combinations per result.

As far as totalling them all within the algorithm how long does it take your computer to calculate the probability of rolling 342 when rolling 100d1000?

What we need is a formula that gives of the number of sets to a specific result. I suggest we work with sets of d3 and after we've got something we think works we can code it an extrapolate.

Here are the tables for 2d3,3d3 & 4d3
2d3
r tr
2 1
3 2
4 3
5 2
6 1

3d3
r tr
3 1
4 3
5 6
6 7
7 6
8 3
9 1

4d3
r tr
4 1
5 4
6 10
7 16
8 19
9 16
10 10
11 4
12 1

It appears that the maximum happens at n * (s-1).
The minimums are always at min & max.
We now need something that will give us the gradation we seek.

In case anyone is curious my excel sheet that I used to do this is attached.
 

Attachments


Remove ads

Top