genBetter.py (582B)
1 import matplotlib.pyplot as plt 2 import seaborn as sns 3 import random 4 5 x = [] 6 y = [] 7 for i in range(0,100): 8 rnd = (random.random() * 300) + 100 9 rndAdd = rnd + (random.random() * 140 - 70) 10 11 x.append(rndAdd) 12 13 if rnd > (286-249)/2 + 249: 14 y.append(1) 15 else: 16 y.append(0) 17 plt.scatter(x,y, c=y, cmap='bwr') 18 plt.axvline((286-249)/2 + 249) 19 20 # plt.show() 21 22 wrong = 0 23 for i in range(0,len(x)): 24 if x[i] > (286-249)/2 + 249: 25 if y[i] == 0: 26 wrong += 1 27 else: 28 if y[i] == 1: 29 wrong += 1 30 print((len(x) - wrong) / len(x))