Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from random import choice
- import matplotlib.pyplot as plt
- al = [(x,x+1/15) for x in np.arange(0,1,1/15) ]
- def ex(N):
- n = 0
- for i in range(N):
- x = np.random.uniform(0,1)
- a1,a2,a3 = choice(al),choice(al),choice(al)
- if (x>a1[0] and x<a1[1]) or (x>a2[0] and x<a2[1]) or (x>a3[0] and x<a3[1]):
- n += 1
- return n/N
- a1 = [1,100,1000,10000,100000]
- a2 = [ex(i) for i in a1]
- plt.plot(a1,a2)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement