TheAceHome

Untitled

Oct 13th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. from random import randint
  2. import matplotlib
  3. import matplotlib.pyplot as plt
  4. A = B = C = D = E = F = 0
  5. N=10000
  6. x1 = []
  7. y1 = []
  8. a,b,aa,bb,aaa,bbb,c,d,cc,dd,ccc,ddd=[],[],[],[],[],[],[],[],[],[],[],[]
  9.  
  10. for i in range(N):
  11. x = randint(0, 60)
  12. y = randint(0, 60)
  13. if (0 <= abs(x - y) <= 15):
  14. A += 1
  15. a.append(x)
  16. b.append(y)
  17. if ((y - x) >= 15) or ((x - y) >= 15):
  18. B += 1
  19. aa.append(x)
  20. bb.append(y)
  21. if (y >= x) and ((y - x) <= 15):
  22. C += 1
  23. aaa.append(x)
  24. bbb.append(y)
  25. if (y > 30 or x > 30) and (0 <= abs(y - x) <= 15):
  26. D += 1
  27. c.append(x)
  28. d.append(y)
  29. if (y - x) > 15:
  30. E += 1
  31. cc.append(x)
  32. dd.append(y)
  33. if (y > 55 or x>55) and (0 <= abs(y - x) <= 15) :
  34. F += 1
  35. ccc.append(x)
  36. ddd.append(y)
  37. print(A/N, B/N, C/N, D/N, E/N, F/N)
  38.  
  39. xmin, xmax, ymin, ymax = plt.axis([0, 60, 0, 60])
  40. plt.plot(a,b, linestyle="",marker="o")
  41. plt.show()
  42. xmin, xmax, ymin, ymax = plt.axis([0, 60, 0, 60])
  43. plt.plot(aa,bb, linestyle="",marker="o")
  44. plt.show()
  45. xmin, xmax, ymin, ymax = plt.axis([0, 60, 0, 60])
  46. plt.plot(aaa,bbb, linestyle="",marker="o")
  47. plt.show()
  48. xmin, xmax, ymin, ymax = plt.axis([0, 60, 0, 60])
  49. plt.plot(c,d, linestyle="",marker="o")
  50. plt.show()
  51. xmin, xmax, ymin, ymax = plt.axis([0, 60, 0, 60])
  52. plt.plot(cc,dd, linestyle="",marker="o")
  53. plt.show()
  54. xmin, xmax, ymin, ymax = plt.axis([0, 60, 0, 60])
  55. plt.plot(ccc,ddd, linestyle="",marker="o")
  56. plt.show()
Add Comment
Please, Sign In to add comment