-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.py
170 lines (122 loc) · 4.28 KB
/
code.py
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import numpy as np
import time
import matplotlib.pyplot as plt
TYPES = ["fast", "middle", "slow"]
def start():
start_time = time.time()
return round((time.time() - start_time) * 1000)
def perceptualstep(type="middle"):
if type == "fast":
t_percept = 50
elif type == "slow":
t_percept = 200
else:
t_percept = 100
start_time = time.time()
return round((time.time() - start_time) * 1000) + t_percept
def cognitivestep(type="middle"):
if type == "fast":
t_cog = 25
elif type == "slow":
t_cog = 170
else:
t_cog = 70
start_time = time.time()
return round((time.time() - start_time) * 1000) + t_cog
def motorstep(type="middle"):
if type == "fast":
t_motor = 30
elif type == "slow":
t_motor = 100
else:
t_motor = 70
start_time = time.time()
return round((time.time() - start_time) * 1000) + t_motor
def example1():
total_time = start()
total_time += perceptualstep()
total_time += cognitivestep()
total_time += motorstep()
return total_time
def example2(completeness="extremes"):
time_list = []
if completeness == "extremes":
for type in TYPES:
total_time = start()
total_time += perceptualstep(type=type)
total_time += cognitivestep(type=type)
total_time += motorstep(type=type)
time_list.append(total_time)
elif completeness == "all":
for type_i in TYPES:
for type_j in TYPES:
for type_z in TYPES:
total_time = start()
total_time += perceptualstep(type=type_i)
total_time += cognitivestep(type=type_j)
total_time += motorstep(type=type_z)
time_list.append(total_time)
plt.boxplot(time_list)
plt.show()
return time_list
def example3():
time_list = []
for type_i in TYPES:
for type_j in TYPES:
for type_z in TYPES:
total_time = start()
total_time += perceptualstep(type=type_i)
total_time += perceptualstep(type=type_i)
total_time += cognitivestep(type=type_j)
total_time += cognitivestep(type=type_j)
total_time += motorstep(type=type_z)
if type_i == "fast" and type_j == "middle" and type_z == "slow":
print(total_time)
time_list.append(total_time)
return time_list
def example4():
stimulus2_time_options = [40, 80, 110, 150, 210, 240]
time_list = []
for stimulus2_time in stimulus2_time_options:
for type_i in TYPES:
for type_j in TYPES:
for type_z in TYPES:
total_time = start()
total_time += perceptualstep(type=type_i)
total_time += perceptualstep(type=type_i) + stimulus2_time
total_time += cognitivestep(type=type_j)
total_time += cognitivestep(type=type_j)
total_time += motorstep(type=type_z)
time_list.append(total_time)
return time_list
def example5():
error = 0.01
error_dict = {"fast": 3, "middle": 2, "slow": 0.5}
time_list = []
error_list = []
for type_i in TYPES:
for type_j in TYPES:
for type_z in TYPES:
total_time = start()
total_time += perceptualstep(type=type_i)
total_time += perceptualstep(type=type_i)
error += error * error_dict[type_i]
total_time += cognitivestep(type=type_j)
total_time += cognitivestep(type=type_j)
error += error * error_dict[type_j]
total_time += motorstep(type=type_z)
error += error * error_dict[type_z]
time_list.append(total_time)
error_list.append(error)
error = 0.01
#print(error_list)
plt.scatter(np.array(time_list), np.array(error_list))
plt.xlabel("time (ms)")
plt.ylabel("error (%)")
plt.title("Time and Error for Human Processor Task for Different Input Types")
plt.show()
return
def main():
print(example5())
if __name__ == '__main__':
main()