Advertisement
TheAceHome

Untitled

Oct 14th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. import random
  2. from matplotlib import pyplot as plt
  3. import numpy as np
  4. #3.14
  5. N=100000
  6. x1=[x for x in range(0,N,100)]
  7. x1.remove(x1[0])
  8. y1=[]
  9. a,b,x,y=0.5,0.75,0,1
  10. n=0
  11. for i in range (N):
  12. c=np.random.uniform(0,1)
  13. if c>a and c<b:
  14. n+=1
  15. if i in x1:
  16. y1.append(n/i)
  17.  
  18.  
  19.  
  20. print(n/N)
  21. plt.plot(x1,y1)
  22. plt.title('PLOT')
  23. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement