Go to the documentation of this file.00001 import math
00002 import numpy as np
00003 import pylab as pb
00004 import sys
00005
00006
00007
00008 coin_success_prob = float(sys.argv[1])
00009 counts = []
00010 for i in range(1000):
00011 success = False
00012 count = 0
00013 while not success:
00014
00015 a = np.random.rand()
00016 if a > coin_success_prob:
00017 success = True
00018 else:
00019 count = count + 1
00020 counts.append(count)
00021
00022 print np.mean(counts)
00023 print np.std(counts)
00024
00025 pb.hist(counts)
00026 pb.show()
00027