1

I am trying to program something to find out the probability of all sum possible when I throw $X$ dice, sum all the face showing $1,2,3,4$ then I minus $Y$ from that sum (with a minimum of $0$, no negative), then I add the sum of face showing $5,6$.

Example: 3 dices minus 7

$1,3,6$ would result $6$

$4,2,3$ would result $2$

$3,5,6$ would result $11$

I need a simple formula to get the probability of all possible results. No fancy symbol please (or else explain what they means, I am not good with statistic terms and even less with english statistic terms :))

Thanks.

math_man
  • 1,574
Wildhorn
  • 125
  • There isn't even a simple formula for the probability of each sum of $X$ dice, even without the complicated subtraction condition, so you're going to have to settle for a good algorithm to compute this. – Mike Earnest Sep 30 '14 at 01:26
  • By simple formula I mean one that use symbol that are useable in computer langage. – Wildhorn Sep 30 '14 at 02:08
  • I do not understand what Y is and how it is computed. – bobbym Sep 30 '14 at 03:23
  • Y is a chosen number, just like X.

    Basically you could see it as a game where you throw Xd6 to determinate damage, Y represente armor (which reduce total damage), but 5s and 6s can't be reduced by said armor.

    – Wildhorn Sep 30 '14 at 04:15

1 Answers1

2

The simpler formula is a generating function as I showed to you yesterday.

A generating function is a polynomial that can represent many things but essentially the coefficients of the polynomial represent the frequency of the value of it exponent.

By example: to represent a simple dice that go from 1 to 6 the generating function will be

$$f(x)=\sum_{k=1}^{6}x^k=x+x^2+x^3+x^4+x^5+x^6$$

For a dice of 10 sides with sides $s=\{0,0,0,1,1,1,2,2,3,4\}$ it generating function will be

$$f(x)=3x^0+3x^1+2x^2+x^3+x^4$$

Now that you know how setup generating functions for dice you can multiply polynomials to know the frequency and sums of throwing a different amount of dice (equals or different). If you put some special rule for a game you can multiply just some powers of a dice and not others.

By example: throwing 2 standard dice of 6 sides

$$f(x)=(x+x^2+x^3+x^4+x^5+x^6)^2=\\=x^{12}+2 x^{11}+3 x^{10}+4 x^9+5 x^8+6 x^7+5 x^6+4 x^5+3 x^4+2 x^3+x^2$$

Your question is really far to be clear but I think I understand. This formula

$$f(x)=x^{-Y}\sum_{k=1}^{X}(x+x^2+x^3+x^4)^k$$

let all the possible and different sums of the sides $\{1,2,3,4\}$ of X dice and after subtract the Y value. So we need to discard from this polynomial the elements with negative exponents. I dont know a clear way to do this on mathematics but you can program it.

A pure mathematical approach to know the frequencies of these sums just for positive sums need the use of this formula. Sry, fancy symbols for you man :).

We have that the frequency for a sum $S\in \{1,..,4k\}$ will be

$$\nu(S,k,4)=\sum_{j=0}^{\lfloor(S-k)/4\rfloor}(-1)^j\binom{k}{j}\binom{S-4j-1}{k-1}$$

(The $\lfloor x\rfloor$ is the floor function and the $\binom{n}{k}$ is the binomial coefficient. You need to know some "fancy symbols" sry. And if upper limit of a summation is lesser than it starting point you get then an empty sum.)

From here our polynomial with just positive exponents will be

$$f^*(x)=x^{-Y}\sum_{k=1}^{X}\sum_{S=1}^{4k}\nu(S,k,4)\cdot x^S\cdot\delta_{|S{-}Y|,S{-}Y}$$

where the $\delta$ is the Kronecker delta that discards all $S-Y<0$

This $f^*(x)$ isnt the complete distribution of sums because we need to add all the combinations with the 5s and 6s. This is done completing the above formula with the others dice that complete the throw and have the values of 5s and 6s

$$f(x)=\sum_{k=1}^{X}\left((x^5+x^6)^{X-k}\left(x^{-Y}\sum_{S=1}^{4k}\nu(S,k,4)\cdot x^S\cdot\delta_{|S{-}Y|,S{-}Y}\right)^{\delta_{|4k{-}Y|{,}4k{-}Y}}\right)$$

The Kronecker delta as an exponent prevents the zero when $4k-Y\leq 0$, using the standard convention that $0^0=1$ (not confuse with $\lim_{x\to a}f(x)=0^0$ that is a undetermined form).

I dont know a more simple way to express this on mathematical terms. On programs languages is easy to setup anything of these tasks using conditions and loops.

I tried dont use any "fancy symbol" but I think a summation, binomial coefficient, floor function and the Kronecker delta is enough simple to understand to somebody not extremely lazy with basic arithmetic knowledge.

Masacroso
  • 30,417
  • 1
    Ouf... thanks alot. Not lazy, but not easy to read math terms in english (already i have difficulty in my native langage, hehe). I will read (and try to understand) during my lunch break. – Wildhorn Sep 30 '14 at 11:25
  • 1
    Some questions: What the k=1 (under the fancy E) represent (the j=0 and the S=0 while we are at it)? What does the v represent? – Wildhorn Sep 30 '14 at 11:30
  • @Wildhorn, if you have any question I will try to show to you on the more easy way. Yeh, it is a bit disturbing to write in a non-native language, Im not english speaker either. Try to use the chat for basic questions on terminology or so. – Masacroso Sep 30 '14 at 11:31
  • Already asked questions :) – Wildhorn Sep 30 '14 at 11:32
  • Go to the chat to get your answer, I cant talk here properly. Is here. – Masacroso Sep 30 '14 at 11:32