-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileReaderAndAverager.py
More file actions
81 lines (48 loc) · 1.29 KB
/
Copy pathFileReaderAndAverager.py
File metadata and controls
81 lines (48 loc) · 1.29 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
import numpy
import numpy as np
import numpy as np
def reject_outliers(data):
u = np.mean(data)
s = np.std(data)
filtered = [e for e in data if (u - 3 * s < e < u + 3 * s)]
return filtered
d = [2, 4, 5, 1, 6, 5, 40]
filtered_d = reject_outliers(d)
def read(filename):
with open(filename) as f:
content = f.readlines()
for i in range(0, len(content)):
content[i] = float(content[i])
return content
a = read("a.txt")
b = read("b.txt")
def mean(listname):
avg = sum(listname) / float(len(listname))
return avg
a = reject_outliers(a)
b = reject_outliers(b)
meana = mean(a)
meanb = mean(b)
print "Mean of A:", meana
print "Mean of B:", meanb
def comparator(x, y):
return str(((x / y) * 100) - 100) + "%"
if meana > meanb:
print "Experiment A was more successful. It showed results larger by: "
print comparator(meana, meanb)
elif meana < meanb:
print "Experiment B was more successful. It showed results larger by:"
print comparator(meanb, meana)
else:
print "The experiments yielded the same result"
print """
Standard deviation of experiment A:"""
print numpy.std(a)
print """
Standard deviation of experiment B:"""
print numpy.std(b)
"""
for i in range (0, len(a)):
if (a(i) - meana) > 3:
a.remove(i)
"""