[Math] Odds of two dice roll

diceprobabilitystatistics

If we roll two dice, what are the odds that we roll one five OR the sum of the rolled dice equals an odd number?

The odds of rolling one five from two dice rolls is $\frac{1}{36}$. The odds of rolling an odd number from the sum of two rolls requires that we roll one even number from one die and an odd number from another die. The odds of this happening are $\frac{1}{2}$.

Therefore, the odds of either even occuring should be: $\frac{1}{36} + \frac{1}{2} = \frac{19}{36}$

However, this is incorrect. Apparently the answer is $\frac{23}{36}$. I do not understand why. I wrote a python script to evaluate my odds:

import random

def rolldice(count):
    return [random.randint(1, 6) for i in range(count)]

def compute_odd(dice):
    return sum(dice) % 2 == 1

def has_num_only(dice, num):
    return dice.count(num) == 1

g_iEvents = 0
g_iSimulations = 8888

for i in range(g_iSimulations):
    dice = rolldice(2)
    if compute_odd(dice) or has_num_only(dice, 5):
        g_iEvents += 1

print( float(g_iEvents) / float(g_iSimulations) )
print( g_iEvents )
print( g_iSimulations )

After several runs, I keep getting the answer of 61% – Therefore this is showing that both answers are incorrect.

Best Answer

When you roll 2 dice there are 36 equally likely options, starting at double one, $(1,1)$, and going all the way to double six, $(6,6)$. Of these, there are 11 equally likely ways to roll a $5$, $(1,5), (2,5), (3,5), (4,5), (5,5), (6,5), (5,1), (5,2), (5,3),(5,4),(5,6)$, so the odds of rolling a 5 is $\frac{11}{36}$.

Similarly there are 18 equally likely ways to roll an odd number (I'll let you think about which combinations these are), so the odds of rolling an odd number are $\frac{18}{36}=\frac{1}{2}$.

At this point you may think the odds of rolling a $5$ or and odd number should be $\frac{11}{36}+\frac{18}{36}=\frac{29}{36}$, however this is not the case. Note that six of the rolls contain both a $5$ and are odd:

$(2,5), (4,5), (6,5), (5,2), (5,4),(5,6)$

If we just add the two probabilities, we'll count these situations twice, even though they're no more likely to occur than any other combination! In reality there are only $11+18-6=23$ dice rolls which contain a $5$ or are odd (see if you can list them), and so the odds of rolling either a $5$ or an odd combination is $\frac{11}{36}+\frac{18}{36}-\frac{6}{36}=\frac{23}{36}$.

This is a simple application of the "principle of inclusion and exclusion", which you may want to look up.

Related Question