Probability of Five Distinct Faces When Five Dice Are Rolled

2k Views Asked by At

This question is very similar to one asked on Probability of All Distinct Faces When Six Dice Are Rolled

Now mine has a little spin on it and is: if five fair dice are rolled what is probability that FIVE numbers will appear exactly once?

If anyone is interested, my main goal is making a python script that can calculate the probability, since I'm new to this, this is what I got (though am positive it's wrong):

def numOne(roll):
  return len([dice1 for dice1 in roll if dice1 == 1])
def numTwo(roll):
  return len([dice2 for dice2 in roll if dice2 == 2])
def numThree(roll):
  return len([dice3 for dice3 in roll if dice3 == 3])
def numFour(roll):
  return len([dice4 for dice4 in roll if dice4 == 4])
def numFive(roll):
  return len([dice5 for dice5 in roll if dice5 == 5])
def numSix(roll):
  return len([dice6 for dice6 in roll if dice6 == 6])

r = range(1,7)
sample = [(i,j,k,l,m) for i in r for j in r for k in r \ 
                      for l in r for m in r]
event = [roll for roll in sample if numOne(roll)==1 and numTwo(roll)==1 and 
numThree(roll)==1 and numFour(roll)==1 and numFive(roll)==1 or 
numSix(roll)==1]

print(len(event) / len(sample))

The output is: 0.417309670781893 or 3245 / 7776

1

There are 1 best solutions below

1
On BEST ANSWER

I don't know enough about Python to see what is going wrong, but yes, something is wrong.

You can easily calculate the probability like this:

If you want five different faces, then for the first die you have $6$ possibilities, then for the second there will be $5$ left, then for the third there will be $4$ left, etc.

So, out of $6^5=7776$ possible outcomes, there will be $6\cdot 5 \cdot 4 \cdot 3 \cdot 2=720$ where the five dice have different faces.

Thus, the probability is $$\frac{720}{7776}$$