The Binomial distribution gives the formula for the probability of observing \(k\) heads when flipping \(n\) coins. Can we find a formula for the probability of getting a total of \(p\) points when rolling \(n\) dice?
The probability of obtaining \(p\) points on \(n\)\(s\)-sided dice can be computed as the coefficient of \(x^p\) in
\[f(x)=(x+x^2+...+x^s)^n\]
since each possible arrangement contributes one term.
But \(p-sk-n>0\) only when \(k<(p-n)/s\), so the other terms do not contribute. Furthermore, applying the symmetric property of the binomial formula, we have
\[\binom{p-sk-1}{p-sk-n}= \binom{p-sk-1}{n-1}\]
Therefore, the probability of getting \(p\) points when rolling \(n\)\(s\)-sided dice is given by
We can verify our formula by simulating the dice rolling game.
set.seed(0)# simulates rolling n dice and returns the sumroll_dice <-function(n, s=6) {sum(sample(seq(1,s), n, replace = T))}# rolling 10 dice 1000 times and collect the resultspoints <-replicate(1000, roll_dice(10))# distribution of the sum of pointshist(points, freq = F)
# formula for computing probability of dice pointsdice_formula <-function(p, n, s=6) { prob <-1/s^n*sum(sapply(seq(0, floor((p-n)/s)), function(k) (-1)^k*choose(n,k)*choose(p-s*k-1,n-1)))}# computing the probability of getting 20-50 when rolling 10 dicex <-20:50; y <-sapply(x, function(p) dice_formula(p,n=10))# overlay the formula on the histogram# it turns out the formula does a nice job!hist(points, ylim =c(0, 0.07), freq = F)lines(x, y, col =2, lwd=2)