Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. a = 0.5
  3. b = 0.75
  4. nl = [1,10,100,1000,10000,100000]
  5. N, n = 1000000, 0
  6. def ex(N):
  7. n = 0
  8. for i in range(N):
  9. x = np.random.uniform(0,1)
  10. if x>a and x<b:
  11. n+=1
  12. return n/N
  13. n2 = [ex(i) for i in nl]
  14. plt.plot(nl,n2)
  15. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement