• The VOIDRUNNER'S CODEX is coming! Explore new worlds, fight oppressive empires, fend off fearsome aliens, and wield deadly psionics with this comprehensive boxed set expansion for 5E and A5E!

Probability Distribution of Dice


log in or register to remove this ad

frisbeet

First Post
Sure thing. I made an error in the orignal formula (since corrected), which might have thrown you off: ...IF[oc<(i*n+s)... should read ...IF[oc<(i*s+n)...

Here's the logic behind the formula

# ways = COMB(oc-1,n-1) + SUM(i=1,n-1) {(-1)^i * IF[oc<(i*s+n),0,COMB(n,i)*COMB(oc-i*s-1,n-1)]}
_____________________________________________
The 1st term COMB(oc-1,n-1):

As posted by Drawmack, presented by K. Ross & C. Wright (Discrete Mathematics (Fourth Edition) by: Kenneth A. Ross & Charles R.B. Wright ISBN: 0-13-096141-8). The total number of ways of summing to a number, oc, with n whole numbers is COMB(oc+n-1,n-1). Think of n-1 as the number of partitions between sets of identical objects, with each set representing a number. The total of all identical objects among all sets is oc.

Ok. To get an oc of 10 with n of 4 means that COMB(oc+n-1,n-1) counts ways like 10|0|0|0, 9|1|0|0, 9|0|1|0, 7|1|1|1, etc. But in our case 10|0|0|0, 9|1|0|0, 9|0|1|0 are examples of ways which shouldn't be counted, because we're using dice to generate our numbers. With 4 dice you'd instead build from 1|1|1|1, using oc-4 as the # of objects to arrange around n-1 partitions. Hence, COMB(oc+n-1-n,n-1) = COMB(oc-1,n-1)

Now, back to the 4d6 outcome 17 example. As I've shown above, the 1st term is COMB(16,3), which is 560.
_______________________________________________
The 1st corrective term -IF[oc<(n+s),0,COMB(n,1)*COMB(oc-s-1,n-1)]}:

For this example,

17 is not less than 4+6, so this term is -COMB(4,1)*COMB(17-6-1,3) = -4*COMB(10,3) = -480.

What does it mean? The problem with the 1st term is that for an outcome like 17 with 4d6, it counts ways like 7|6|3|1. But you can't roll a 7 with a six-sided die, unless you're blitzed. How many ways were erroneously counted? For now just consider the example of one set having at least a 7 (one d6 rolled at least a 7). This leaves behind 17 - 7 - 3 (the other sets still have to have at least one identical object) = 7 objects to place around 3 partitions--you can still place more objects in the 7-hole, getting a higher #. Hence COMB(7+3,3). But wait, this assumes one die has at least a 7--but which one? The 1st term erroneously counted all 4 possibilities, or COMB(4,1). So 7|6|3|1, 6|7|3|1, 6|3|7|1, & 6|3|1|7. Ok, generalizing, we get the 1st corrective term.
________________________________________________
The 2nd corrective term (-1)^2IF[oc<(2s+n),0,COMB(n,2)*COMB(oc-2s-1,n-1)]}:

For this example,

17 is not less than 2*6+4, so this term is +COMB(4,2)*COMB(17-12-1,3) = +6*COMB(4,3) = +24.

This is a correction to the correction. 17 is one of the bigger outcomes for 4d6; one erroneous way to get it is to roll 7|7|2|1.
How many of these terms are there? Restrict two sets to have at least 7, and the other two to have at least one. Then that's 17 - 14 - 2 = 1 object to put around 3 partitions, so figure the combination of 4 things taken 3 (or one) at a time. Or that's 17(oc) - 4(at least one object/set) - 2*6(2 sets have at least six more objects) + 3(partitions) = 17-2*6-1 = 4 things, 3 of which are identical (partitions). Hence, COMB(4,3), generalized to COMB(oc-2*s-1,n-1). But any two sets can be 7s or greater. There are COMB(4,2) ways of arranging 2 sets among 4 where each set is only distinguished by weather it has 7 or more or 6 or less objects. So that's COMB(4,2), or COMB(n,i), generalized. Multiply by COMB(oc-2*s-1,n-1) to get total # of ways to roll (at least 7)|(at least 7)|(6 or less)|(6 or less).

But why is it a correction of the 1st correction? Because for every 7|7|2|1, the 1st correction subtracts twice. Suppose you needed to put just a few more object into
(at least 7)|(exactly 6)|(6 or less)|(6 or less). Usually, if you assign the remaining objects, you'll get (at least 7)|(6 or less)|(6 or less)|(6 or less), like 8|6|2|1 or 7|6|3|1. The 1st correction subtracts these impossibilities away. The exception is when you have (at least 7)|(at least 7)"|(6 or less)|(6 or less). You want to subtract this term away once, but the 1st correction counts (at least 7)|(at least 7)"|(6 or less)|(6 or less) and (at least 7)"|(at least 7)|(6 or less)|(6 or less) as separate things.
________

And so on. This correction-for-a-correction-for-a-correction business gets pretty confusing, and I'm not even sure I've grasped the idea right. What is nice is that it does work for every die combo I've tested.

Hope your forehead hasn't struck your keyboard spasmodically.


HUGE EDIT:

2nd correction corrected. Big sorry folks. Thanks a lot Storminator!
 
Last edited:

Storminator

First Post
Whoa Nellie!

That's gonna confuse the hell out of folks frisbeet. Your 2nd corrective term is all wrong. The explanation is right, but everything is green below is from the first corrective term, not the second.
The 2nd corrective term +IF[oc<(2s+n),0,COMB(n,2)*COMB(oc-2s-1,n-1)]}:

For this example,

17 is not less than 2*6+4, so this term is -COMB(4,1)*COMB(17-6-1,3) = -4*COMB(10,3) = -480.

The green part should be replaced with

(-1)^2*COMB(4,2)*COMB(17-2*6-1,3) = 6*COMB(4,3) = 24

Then it all works. Very nice work frisbeet.

PS
 

frisbeet

First Post
True enough Storminator. Was in a hurry, and I was starting to confuse myself posting that reply. So it's corrected now, but let the record show that originally the 2nd term in my example was quite wrong.

I'd like to see how this checks out with lots of dice handled by some of the recursive code in this thread.
 


ichabod

Legned
I'm going to try to look it over too. However, I just tried to understand a high speed presentation on properly calculating sample sizes for studies with adaptive randomization, so I think I'll wait until my brain is a little less fried.
 

LazarusLong42

First Post
Heh. I just stumbled across this. Had I mentioned I loved statistics? But darn it, all the fun has been figured out already...

Frisbeet has the general idea correct; I'm going to see if I can't summarize it a bit more clearly, because while I know what he's trying to say, I'm having trouble with his symbology (no offense, it might be just me). Then again, I might just make it worse... :)

The major problem is that linear combination/permutation does not work for numbers smaller than 0. To get around this, define the last i in the series by what the result is. That gets around all the IFs and "corrections" and so forth. So....

For a set of n identical dice with d sides, for the probability of achieving result R, we have:

dice.jpg


The weird half-brackets are the floor function, which truncates the quotient to an integer sans remainder (this is (int)$n for you programmers). The numbers one on top of the other in parentheses are the combination function (AKA binomial function)--what frisbeet (and Excel) call COMBIN(n,i).

This formula gives only the numerator, of course, and only for a set of identical dice. The denominator is easily calculated.

Dissimilar dice (say sneak attack with a longsword, 1d8 + 2d6)... are a bit more difficult. I'll try my hand at it later.
 


Mr. Draco

First Post
Hey. just found this interesting thread, and unfortunately it looks like all the fun has been had already. But, I have a hunch about something that may work for the denominator without involving summation notation. I'll get back to you guys when I have a chance to test it for a bit.
 

Riveneye

First Post
The demoninator will just be s^n where s = sides of dice and n = number of dice. We worked that out on page one ;)

Great work there LazarusLong42, and everyone else who helped (especially frisbeet and Drawmack). We've almost got a perfect answer now (one involving different types of dice), so I think all the hard work is paying off :D
 

Remove ads

Top