Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. import  numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. repetition = 3000
  5. radius = 10
  6.  
  7. x1 = []
  8. y1 = []
  9.  
  10. for i in range(repetition):
  11.     x = np.random.uniform(-radius, radius)
  12.     y = np.random.uniform(-radius, radius)
  13.     if (x**2 + y**2 < radius**2):
  14.         x1.append(x)
  15.         y1.append(y)
  16.  
  17. fig = plt.figure()
  18. ax = fig.add_subplot(111)
  19. ax.set_xlim([-radius, radius])
  20. ax.set_ylim([-radius, radius])
  21. ax.scatter(x1, y1, color = 'magenta')
  22. # circle1 = plt.Circle((0, 0), radius, color = 'b', fill=False)
  23. # ax.add_artist(circle1)
  24.  
  25. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement