-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.py
More file actions
101 lines (85 loc) · 2.43 KB
/
data.py
File metadata and controls
101 lines (85 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import numpy as np
import csv
dataSheet = []
dataA = []
dataB = []
dataC = []
dataD = []
dataE = []
dataF = []
dataG = []
ProbabilityA = []
ProbabilityB = []
ProbabilityC = []
ProbabilityD = []
ProbabilityE = []
ProbabilityF = []
ProbabilityG = []
with open('probabilityDistribution.csv', 'r+') as f:
fr = csv.reader(f)
i = 0
for row in fr:
i += 1
if i < 15:
dataA.append(int(row[0]))
ProbabilityA.append(float(row[1][:-1])/100)
elif i < 37:
dataB.append(int(row[0]))
ProbabilityB.append(float(row[1][:-1])/100)
elif i < 66:
dataC.append(int(row[0]))
ProbabilityC.append(float(row[1][:-1])/100)
elif i < 93:
dataD.append(int(row[0]))
ProbabilityD.append(float(row[1][:-1])/100)
elif i < 119:
dataE.append(int(row[0]))
ProbabilityE.append(float(row[1][:-1])/100)
elif i < 141:
dataF.append(int(row[0]))
ProbabilityF.append(float(row[1][:-1])/100)
else:
dataG.append(int(row[0]))
ProbabilityG.append(float(row[1][:-1])/100)
while True:
A = np.random.choice(np.asarray(dataA),p = ProbabilityA)
B = np.random.choice(np.asarray(dataB),p = ProbabilityB)
if B <= A:
continue
C = np.random.choice(np.asarray(dataC), p=ProbabilityC)
if C <= B:
continue
D = np.random.choice(np.asarray(dataD), p=ProbabilityD)
if D <= C:
continue
E = np.random.choice(np.asarray(dataE), p=ProbabilityE)
if E <= D:
continue
F = np.random.choice(np.asarray(dataF), p=ProbabilityF)
if F <= E:
continue
G = np.random.choice(np.asarray(dataG), p=ProbabilityG)
if G <= F:
continue
newRow = [A,B,C,D,E,F,G]
if newRow in dataSheet:
continue
npRow = np.asarray(newRow)
if npRow.sum() < 138 or npRow.sum() > 210:
continue
if npRow.mean() < 20 or npRow.mean() >30:
continue
if newRow[6] - newRow[0] < 30 or newRow[6] - newRow[0] > 44:
continue
rowRoot = np.power(npRow, 1./7)
if np.prod(rowRoot) < 10.54 or np.prod(rowRoot) > 25.18:
continue
if npRow.std() < 11.0001 and npRow.std() > 16.0001:
continue
dataSheet.append(newRow)
if len(dataSheet) == 2000:
break
with open('Result.csv', 'w+') as f:
fw = csv.writer(f)
for rw in dataSheet:
fw.writerow(rw)