
JJ G.
asked 02/21/21Monte Carlo Method question
You receive one of five distinct coupons uniformily at random each day. Use the Monte Carlo Method to estimate to within .01 days, the expected number of days until you collect two copies of each of the five coupons.
Can be done in python
1 Expert Answer

Patrick B. answered 02/21/21
Math and computer tutor/teacher
import random
N=10000
A=[False,False,False,False,False]
sum=0
for i in range(N):
done=False
count=0
A=[False,False,False,False,False]
while not done:
iRandIntNum=random.randint(0,4)
count = count+1
A[iRandIntNum]=True
done = (A[0]==True) and (A[1]==True) and (A[2]==True) and (A[3]==True) and (A[4]==True)
sum=sum+count
#print(str(count))
print("---------------------")
#print("sum is " + str(sum))
print(sum/N)
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Patrick B.
I'm seeing 11.x %02/21/21