# Probability of X 5's or 6's given Y Dice

I am an avid board game player, especially ones with miniatures that duke it out (Risk, Axis and Allies, etc.) and I'm trying to analyze efficiency of different units in one of my more recent pickups.

In the game (Battlelore Second Edition for those who are curious), you get a hit on either a 5 or a 6. This would be simple if you're just rolling one die. However, figures in this game roll up from 1 die, all the way up to 5 dice (maybe more in certain situations) and I'm having a bugger of a time figuring out the probability. I set up a table in excel that takes the amount of dice being rolled in the column, and checks the probability of getting 1, 2, 3, 4 or 5 hits in each respective row. I'd rather not list out all of the possibilities and count them, so I'm look for an equation of course.

To sum up: I need an equation(s) that gives Z, the probability of getting X hits with Y dice where hits are on 5's and 6's.

EDIT: I have gotten as far as all of the chances of getting 1 hit with Y dice, as well as the chance of 2 hits with up to 3 dice, but 4 dice with 2 hits and onwards it giving me trouble.

## 2 Answers

This is a binomial distribution with $p = \frac13,$ since that is the probability of rolling a $5$ or $6$ on one die. The probability of exactly $k$ hits on $n$ dice is

$$P_n(k) = \binom nk \left(\frac13\right)^k \left(\frac23\right)^{n-k}$$

where $\binom nk$ is a binomial coefficient; $$\binom nk = \frac{n!}{(n-k)!k!} = \frac{n(n-1)(n-2)\cdots(n-k+2)(n-k+1)}{k(k-1)(k-2)\cdots(2)(1)}.$$

• @Telethia This is a built-in function in Excel: BINOM.DIST. – amd Jun 28 '17 at 23:02

I'm not particularly familiar with programming in Excel, but I do like Python, so here's some code based on David K's excellent answer and this binomial coefficient implementation:

from math import factorial as fac

def binomial(x, y):
try:
binom = fac(x) // fac(y) // fac(x - y)
except ValueError:
binom = 0
return binom

def exact_hit_chance(n, k):
"""Return the probability of exactly k hits from n dice"""
# a hit is a 5 or 6, so 1/3 chance.
return binomial(n,k) * (1/3)**k * (2/3)**(n-k)

def hit_chance(n, k):
"""Return the probability of at least k hits from n dice"""
return sum([exact_hit_chance(n, x) for x in range(k,n+1)])

for dice in range(1,6):
for hits in range(1,6):
chance = hit_chance(dice, hits)
if chance > 0:
print(hits, "hit(s) from", dice, "dice: {:>6.2%}".format(chance))


This produces the following output:

1 hit(s) from 1 dice: 33.33%
1 hit(s) from 2 dice: 55.56%
2 hit(s) from 2 dice: 11.11%
1 hit(s) from 3 dice: 70.37%
2 hit(s) from 3 dice: 25.93%
3 hit(s) from 3 dice:  3.70%
1 hit(s) from 4 dice: 80.25%
2 hit(s) from 4 dice: 40.74%
3 hit(s) from 4 dice: 11.11%
4 hit(s) from 4 dice:  1.23%
1 hit(s) from 5 dice: 86.83%
2 hit(s) from 5 dice: 53.91%
3 hit(s) from 5 dice: 20.99%
4 hit(s) from 5 dice:  4.53%
5 hit(s) from 5 dice:  0.41%


If you want to poke around with the code or change the number of dice you needn't install Python, you can Try-It-Online.