Throw X dice, sum face $1,2,3,4$ minus Y, then add $ 5,6$ formula 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.
 A: 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.
