views:

118

answers:

3

In trying to solve a particular Project Euler question, I ran into difficulties with a particular mathematical formula. According to this web page (http://www.mathpages.com/home/kmath093.htm), the formula for determining the probability for rolling a sum, T, on a number of dice, n, each with number of sides, s, each numbered 1 to s, can be given as follows:

alt text

After I started getting nonsensical answers in my program, I started stepping through, and tried this for some specific values. In particular, I decided to try the formula for a sum T=20, for n=9 dice, each with s=4 sides. As the sum of 9 4-sided dice should give a bell-like curve of results, ranging from 4 to 36, a sum of 20 seems like it should be fairly (relatively speaking) likely. Dropping the values into the formula, I got:

alt text

Since j runs from 0 to 7, we must add over all j...but for most of these values, the result is 0, because at least one the choose formulae results are 0. The only values for j that seem to return non-0 results are 3 and 4. Dropping 3 and 4 into this formula, I got

alt text

Which, when simplified, seemed to go to:

alt text

which eventually simplifies down to ~30.75. Now, as a probability, of course, 30.75 is way off...the probability must be between 0 and 1, so something has gone terribly wrong. But I'm not clear what it is.

Could I misunderstanding the formula? Very possible, though I'm not clear at all where the breakdown would be occuring. Could it be transcribed wrong on the web page? Also possible, but I've found it difficult to find another version of it online to check it against. Could I be just making a silly math error? Also possible...though my program comes up with a similar value, so I think it's more likely that I'm misunderstanding something.

Any hints?

(I would post this on MathOverflow.com, but I don't think it even comes close to being the kind of "postgraduate-level" mathematics that is required to survive there.)

Also: I definitely do not want the answer to the Project Euler question, and I suspect that other people that my stumble across this would feel the same way. I'm just trying to figure out where my math skills are breaking down.

+4  A: 

According to mathworld (formula 9 is the relevant one), the formula from your source is wrong.

The correct formula is supposed to be n choose j, not n choose T. That'll really reduce the size of the values within the summation.

The mathworld formula uses k instead of j and p instead of T:
formula from mathworld

Welbog
+1 That n choose T was really giving me a good headscratch.
Poindexter
This is what I needed to know, and it gives me a great website to go to for future math stuff, and I like lasers. So this is all good.
Beska
+2  A: 

Take a look at article in wikipedia - Dice. The formula here looks almost similar, but have one difference. I think it will solve your problem.

woo
+2  A: 

I'm going to have to show my ignorance here.... Isn't 9 choose 20 = 0? More generally, isn't n choose T going to always be 0 since T>=n? Perhaps I'm reading this formula incorrectly (I'm not a math expert), but looking at de Moive's work, I'm not sure how this formula was derived; it seems slightly off. You might try working up from Moive's original math, page 39, in the lemma.

Rob Napier
This is the problem I was running into early on...(9 choose 20? what?) I figured that I must just be remembering the notation backwards (or upside down), because otherwise it didn't make sense. Turns out it just really didn't make sense.
Beska