The previous posters did a great job of quickly providing the correct answer. I wanted to offer a few tools for thinking about dice problems like this. Hopefully this information will aid others tackling similar problems in the future.
But first a word on notation: "zN" means "a die labeled 0-N". This is called "zero-biased notation" and it comes from this post:
forum.rpg.net/showthread.php?482860-Looking-for-a-new-dice-roll-shorthand-notation&p=11202182#post11202182Problem: Find the probability mass function for the sum of discrete uniform random variables d6+z9, where
d6 = six-sided die
z9 = ten-sided die labeled 0-9
Solution: Lots of different ways to think about this problem:
#1 Use polynomials/generating functions...The generating functions G(x) of these dice are...
d6: x^1+x^2+x^3+x^4+x^5+x^6
z9: x^0+x^1+x^2+x^3+x^4+x^5+x^6+x^7+x^8+x^9
In these functions, the exponent k in the expression x^k represents the number of pips or spots on the die. The coefficient of x^k is the number of ways to get k pips; all the coefficients above are implicitly 1s. Read the plus sign (+) as an exclusive "or". So, the generating function for d6 says, "There's 1 way to get a 1; 1 way to get a 2; ...; or 1 way to get a 6."
Apply the "product rule" from probability theory to get a representation of every outcome from throwing both dice and summing the results:
(x^1+x^2+x^3+x^4+x^5+x^6) * (x^0+x^1+x^2+x^3+x^4+x^5+x^6+x^7+x^8+x^9)
= 1 x^1 + 2 x^2 + 3 x^3 + 4 x^4 + 5 x^5 + 6 x^6 + 6 x^7 + 6 x^8 + 6 x^9 + 6 x^10 + 5 x^11 + 4 x^12 + 3 x^13 + 2 x^14 + 1 x^15
This expression succinctly says:
- There's one way (coefficient of x^1) to roll a 1
- There's two ways (coefficient of x^2) to roll a 2
- Etc.
- There's 6 ways (coefficient of x^10) to roll a 10
- There's 5 ways (coefficient of x^11) to roll an 11
- Etc. Etc.
In other words, the number of outcomes that sum to k is the coefficient of x^k.
The total number of outcomes is 6*10=60.
The probability that the sum is k is the number of outcomes that sum to k divided by the total outcomes (60).
:. The probability that the sum of the dice = k is the coefficient of x^k divided by 60.
In Mathematica, you could write all this in one line as...
Table[{n,100*Coefficient[Expand[Sum[x^n,{n,1,6}]*Sum[x^n,{n,0,9}]],x^n]/60//N},{n,1,15}]//TableForm
Outcome Percentage (%) chance
1 1.66667
2 3.33333
3 5.
4 6.66667
5 8.33333
6 10.
7 10.
8 10.
9 10.
10 10.
11 8.33333
12 6.66667
13 5.
14 3.33333
15 1.66667
As a check, the probabilities must sum to one: Fold[Plus, 0, (Coefficient[Expand[Sum[x^n,{n,1,6}]*Sum[x^n,{n,0,9}]],x^#])/60&/@range[1,15]] = 1 as required.
#2 Use convolutions...The probability mass function of d6 is f(x) = 1/6 for x in 1..6, 0 otherwise.
The probability mass function of z9 is g(x) = 1/10 for x in 0..9, 0 otherwise.
The probability mass function of d6+z9 is the convolution h[n] = (f*g)[n] = Sum[f[m] g[n-m],{m,1,6}] where n in 1..15. Here the asterisk * is the convolution operator, and multiplication is represented by juxtaposition.
You could write this in Mathematica as
f[x_]:= If[x<1 || x > 6, 0, 1/6]
g[x_]:=If[x<0||x>9,0,1/10]
h[n_]:=Sum[f[m] g[n-m],{m,1,6}]
Table[{n,h[n]},{n,1,15}]//TableForm
Here we express probabilities as exact fractions...
1 1/60
2 1/30
3 1/20
4 1/15
5 1/12
6 1/10
7 1/10
8 1/10
9 1/10
10 1/10
11 1/12
12 1/15
13 1/20
14 1/30
15 1/60And again we always check Sum[h[n],{n,1,15}] == 1. True.
Once you have the probability mass function, its easy to compute statistics for this roll...
Mean: Sum[n*h[n],{n,1,15}] = 8
Standard Deviation: Sqrt[Sum[n^2*h[n],{n,1,15}] - (Sum[n*h[n],{n,1,15}])^2] = Sqrt[67/6] ≈ 3.34166
#3 Use the Troll dice roller and probability calculator at topps.diku.dk/torbenm/troll.mspThe expression is: z9 + d6
Click the "Calculate probabilities" button. This confirms the above results. It also confirms the mean (8) and standard deviation (3.34165627596) we already got. Always pays to double check.
Note that z9 == d10 - 1, so you could also have used the expression: d6 + d10 - 1
#4 Write a computer program to enumerate all the outcomes.Here's the Common Lisp code to solve this problem:
;; compute probabilities by enumerating all outcomes
(setf h (make-hash-table)) ; h counts number of each outcome
(loop for x from 1 to 6 ; x = d6
do (loop for y from 0 to 9 ; y = z9
do (let* ((k (+ x y)) (v (gethash k h))) ; k = d6 + z9
(if v
(setf (gethash k h) (1+ v)) ; increment outcome k count by 1
(setf (gethash k h) 1))))) ; initialize outcome k count to 1
; Print list of outcomes k and their probabilities 100%*v/60
(loop for k from 1 to 15
do (let ((v (gethash k h)))
(format t "~d:~10t~f%~%" k (* 100 (/ v 60)))))
You can actually run this code at
www.compileonline.com/execute_lisp_online.phpIt produces output like so:
Executing the code....
$clisp /tmp/136391496511858.lisp
1: 1.6666666%
2: 3.3333333%
3: 5.0%
4: 6.6666665%
5: 8.333333%
6: 10.0%
7: 10.0%
8: 10.0%
9: 10.0%
10: 10.0%
11: 8.333333%
12: 6.6666665%
13: 5.0%
14: 3.3333333%
15: 1.6666666%
Which is exactly what we expect to see.
#5 Write a computer program to simulate a large number of random variates.We can slightly modify the previous program to accomplish this:
;; simulate probabilities by generating two hundred fifty thousand random variates
(setf h (make-hash-table))
(defvar iterations 250000)
(loop for n from 1 to iterations
do (let* ((x (1+ (random 6))) (y (random 10)) (k (+ x y)) (v (gethash k h)))
(if v
(setf (gethash k h) (1+ v))
(setf (gethash k h) 1))))
; Print list of outcomes k and their probabilities 100%*v/iterations
(loop for k from 1 to 15
do (let ((v (gethash k h)))
(format t "~d:~10t~f%~%" k (* 100 (/ v iterations)))))
This produces the following results:
1: 1.6332%
2: 3.2772%
3: 5.0144%
4: 6.6868%
5: 8.414%
6: 10.0452%
7: 10.0404%
8: 10.0156%
9: 9.9716%
10: 9.9524%
11: 8.2184%
12: 6.7016%
13: 4.996%
14: 3.366%
15: 1.6672%
Increasing the number of iterations will increase your accuracy. I increased the number of random variates 40-fold to 10,000,000 and got the following results:
1: 1.6677%
2: 3.32552%
3: 4.98889%
4: 6.67127%
5: 8.33191%
6: 10.01302%
7: 9.99581%
8: 10.00938%
9: 9.99052%
10: 10.02067%
11: 8.32514%
12: 6.65458%
13: 5.00784%
14: 3.33027%
15: 1.66748%
That looks a little better
For example, the error for outcome "3" improved by 3.29 thousandths.