-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess-data.awk
76 lines (75 loc) · 1.25 KB
/
process-data.awk
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
function stdev(sumsq,average,count) {
return sqrt((sumsq/count) - average*average);
} function max(a, b) {
return a < b ? b : a;
} {
if (last=="") {
last=$1;
min2=max2=$2;
total2=0;
sumsq2=0;
count2=0;
min3=max3=$3;
total3=0;
sumsq3=0;
count3=0;
};
if (last!=$1) {
ave2=total2/count2
stdev2=stdev(sumsq2,ave2,count2)
ave3=total3/count3
stdev3=stdev(sumsq3,ave3,count3)
print last, max(ave2-stdev2, 0), ave2, ave2+stdev2, min2, max2, max(ave3-stdev3, 0), ave3, ave3+stdev3, min3, max3
last=$1;
min2=max2=$2;
total2=0;
sumsq2=0;
count2=0;
min3=max3=$3;
total3=0;
sumsq3=0;
count3=0;
}
if ($2>max2) {
max2=$2
};
if ($2<min2) {
min2=$2
};
total2+=$2;
sumsq2+=($2*$2);
count2+=1;
if ($3>max3) {
max3=$3
};
if ($3<min3) {
min3=$3
};
total3+=$3;
sumsq3+=($3*$3);
count3+=1;
} END {
if ($2>max2) {
max2=$2
};
if ($2<min2) {
min2=$2
};
total2+=$2;
sumsq2+=($2*$2);
count2+=1;
if ($3>max3) {
max3=$3
};
if ($3<min3) {
min3=$3
};
total3+=$3;
sumsq3+=($3*$3);
count3+=1;
ave2=total2/count2
stdev2=stdev(sumsq2,ave2,count2)
ave3=total3/count3
stdev3=stdev(sumsq3,ave3,count3)
print last, max(ave2-stdev2, 0), ave2, ave2+stdev2, min2, max2, max(ave3-stdev3, 0), ave3, ave3+stdev3, min3, max3
}