Probability Problem



Problem: Randomly generate 10 integers from 0-100 inclusive, and sum them. Do that twice. What is the probability the two sums are 390 apart?

I have code to do part of it (below), and I know how to write code to do the rest. The part I have calculates the number of ways the dice can come out to a given number. The problem is the main loop has 9 iterations and it takes about 2.5 minutes to begin the 4th one, and each iteration is about 101 times longer than the previous one. So:

>>> x = 2.5 * 101**6
>>> x /= (60*24*365.25)
>>> x
5045631.5622908585

It'd take 5,000 millennia. (If my computer didn't run out of memory after about 4 minutes, that is.)

Any suggestions? Either a way to do the same thing much more efficiently (enough that I can run it) or a different way to solve the problem.

Code:

li = range(101)
li2 = []
range101 = range(101)
for x in xrange(9):
print "x is %s" % x
li2 = []
for y in li:
for z in range101:
li2 += [y+z]
li = li2
print li.count(800)
# prints how many ways the dice can add to 800


This link may help:
http://www.math.csusb.edu/faculty/stanton/m262/intro_prob_models/ calcprob.html

-- Elliot Temple
http://www.curi.us/blog/

.



Relevant Pages

  • Please help with a sum of dice problem
    ... probability, ... which is very important to me (sum of workloads on parallel ... So the average sum of the 4 dices would be the sum of following: ... as each dice is identical, ...
    (sci.math.num-analysis)
  • Please help with a sum of dice problem
    ... probability, ... which is very important to me (sum of workloads on parallel ... So the average sum of the 4 dices would be the sum of following: ... as each dice is identical, ...
    (sci.math)
  • Re: Request
    ... It's based on two fair dice. ... determine what that distribution is quite simply. ... >>>sum of the number of dots on the dice faces. ... >>amount and dividing by 36 will give you the probability of rolling any ...
    (talk.origins)
  • Re: Probability question
    ... A pair of dice, one red and one white, are rolled two successive times. ... What is the probability that the sum of the two dice is the same on ...
    (sci.math)
  • Re: Some more novel dice questions
    ... >> I know this is a very basic question on dice. ... shouldn't the probability of rolling a 11 ... I would have thought you exclude them because they sum to 5. ...
    (sci.math)