Probability Distribution of Dice


log in or register to remove this ad

Yeah, with large dice sets the factorial functions start to give you problems.
Don't you end up with the "recursive" codes generated above in this thread? They have the advantage of allowing different die types, but aren't as mathematically cool to play with.
My code was not recursive, and did not use factorials, it simply summed the probability of generating a result, one dice at a time.
It can be seen here
 

CDS actually has a number of games that are actually based on Craps and Roulette. The Video Craps game was designed by my dad and yes they do use a dice roller in the machine. The computer randomly picks a set of dice and then rolls. CDS knows and could tell you just about anything you want to know about random number generators that is what they do for the Casino/Gaming Industry.

That is a cool site you directed me to but not what I had ment as Casino Games ....Slot machines are a whole different animal and i guess haveing been around the industry for so long i forgot most people only think of SLOT MACHINES when I say Casino Games.

This is an awesome discussion.
Darius
 

Unther the unready said:


My code was not recursive, and did not use factorials, it simply summed the probability of generating a result, one dice at a time.
It can be seen here

Entirely correct. Both nsruf and myself posted essentially the same code. We originally looked at the problem from the largest number of dice and worked backwards, which is recursive. We all quickly realized you could start at the bottom and work up, but to keep the link to the original ideas I was calling the codes "recursive." The quote marks are important here, as the codes aren't recursive at all. And yes, none of them use factorials.

So consider this a rousing endorsement of your code! Good show old man!

PS
 

I'm guilty of propagating the "recursive" code label--sorry!

Can anyone add to LL42's explicit equation for the #ways a single outcome can be achieved for two kinds of dice, each rolled a parameterized # of times? I haven't dived into it yet.
 

Riveneye said:
I got the idea to write a script that would spit out the % chance of getting a certain roll with certain dice in my IRC game (just to feed our curiosity at times), but am stumped on how to write such a script when large amounts of dice are used. As soon as more than 2 dice are introduced, the amount of manual work that I need to do to calculate the probabilities is enormous. Does anyone know of a formula I could use?

If you are only interested in using collections of dice all with the same number of sides, grab an intermediate-level textbook on probability theory or distribution theory and look up "multinomial distribution".

Regards,


Agback
 

Re: More than one die type...

LazarusLong42 said:
All right, I've done some figuring, and about the best I can come up with is the following:

dice2.jpg


where n and d are the number and size of each set of dice; R is the result desired; and N is the total dice. So, for 3d6 + 2d4:

n1 = 3
d1 = 6
n2 = 2
d2 = 4
N = 5

Given this equation and the one above, I think the math-minded people in this thread can easily extrapolate for three or more types of dice. The only problem is how many iterations the algorithm goes for... that is, the definition of m1 and m2 in this equation.

The problem is that there are three criteria:

m1 <= n1;
m2 <= n2;
i*d1 + j*d2 <= R - N

If one defines m1 as in the original equation, one then must find an expression for m2, in terms of n1, n2, d1, d2, R, N, and i. If anyone can find an expression for that, let me know.

Note that the binomial coefficient (n over s) is per definition zero, if s is an integer greater than n (and n positive). Therefore, you don't need the constraints m1 <= n1 and m2 <= n2.
 

I guess I miss understood what people meant by "recursion", which to me is a function which calls itself, e.g. the function posted by Drawmack.

Now I'm normally a fortran programmer, not a C programmer, and recursion is not (usually) allowed because it can cause problems when pushing the hardware of a computer, which many big fortran programs do. So to me, getting accused of using a recursive function is irritating, and I'm inclined to slightly snitty in response. That said, I apologise if my response caused any insult.
 

Re: Re: More than one die type...

Nathan said:
Note that the binomial coefficient (n over s) is per definition zero, if s is an integer greater than n (and n positive). Therefore, you don't need the constraints m1 <= n1 and m2 <= n2.

See, that's the sort of information I miss by not actually being a mathematician, and generally using Excel for the figuring for this. :) Excel gives an error on COMBIN(5,7), but my trusty TI-85 doesn't.

Which makes things a whole lot easier. I'll post later with revisions if I have time.
 

The definition of the binomial coefficient (n over s) for n any number and s any integer with s >= 0 is given by:

(n over s) := (n * (n - 1) * (n - 2) * ... * (n - s + 1))/(1 * 2 * ... * s).

As one can easily check, the nominator includes a factor of zero (and therefore vanishes) if s >= n.
 

Remove ads

Top