Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- import matplotlib
- import matplotlib.pyplot as plt
- A = B = C = D = E = F = 0
- N=10000
- x1 = []
- y1 = []
- a,b,aa,bb,aaa,bbb,c,d,cc,dd,ccc,ddd=[],[],[],[],[],[],[],[],[],[],[],[]
- for i in range(N):
- x = randint(0, 60)
- y = randint(0, 60)
- if (0 <= abs(x - y) <= 15):
- A += 1
- a.append(x)
- b.append(y)
- if ((y - x) >= 15) or ((x - y) >= 15):
- B += 1
- aa.append(x)
- bb.append(y)
- if (y >= x) and ((y - x) <= 15):
- C += 1
- aaa.append(x)
- bbb.append(y)
- if (y > 30 or x > 30) and (0 <= abs(y - x) <= 15):
- D += 1
- c.append(x)
- d.append(y)
- if (y - x) > 15:
- E += 1
- cc.append(x)
- dd.append(y)
- if (y > 55 or x>55) and (0 <= abs(y - x) <= 15) :
- F += 1
- ccc.append(x)
- ddd.append(y)
- print(A/N, B/N, C/N, D/N, E/N, F/N)
- xmin, xmax, ymin, ymax = plt.axis([0, 60, 0, 60])
- plt.plot(a,b, linestyle="",marker="o")
- plt.show()
- xmin, xmax, ymin, ymax = plt.axis([0, 60, 0, 60])
- plt.plot(aa,bb, linestyle="",marker="o")
- plt.show()
- xmin, xmax, ymin, ymax = plt.axis([0, 60, 0, 60])
- plt.plot(aaa,bbb, linestyle="",marker="o")
- plt.show()
- xmin, xmax, ymin, ymax = plt.axis([0, 60, 0, 60])
- plt.plot(c,d, linestyle="",marker="o")
- plt.show()
- xmin, xmax, ymin, ymax = plt.axis([0, 60, 0, 60])
- plt.plot(cc,dd, linestyle="",marker="o")
- plt.show()
- xmin, xmax, ymin, ymax = plt.axis([0, 60, 0, 60])
- plt.plot(ccc,ddd, linestyle="",marker="o")
- plt.show()
Add Comment
Please, Sign In to add comment