Search code examples
pythonprobabilitydice

Probability - comparison 6-sided dices


I am in new probability. Please have me. We have 3 identical 6-sided dices. We role one dice first and the remaining 2 dices after that. What is the probability that the point obtained in the first roll is greater than the sum of points obtained in the second roll?


Solution

  • Since the total number of possibilities is quite small, 6**3, we can simply enumerate them all and count the number of events we are interested in:

    import itertools as IT
    
    hits = 0
    for roll in IT.product(range(1,7), repeat=3):
        if roll[0] > roll[1] + roll[2]:
            hits += 1
            print(roll, roll[1]+roll[2])
    total = 6**3
    print('Probability of first roll > sum of 2 rolls: {}/{} ~= {:.2%}'
          .format(hits,total,hits/total))
    

    reports

    Probability of first roll > sum of 2 rolls: 20/216 ~= 9.26%
    

    (Corrected based on Aniket Rangrej's solution).