forked from gerner/autodevstats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcdf.awk
50 lines (44 loc) · 825 Bytes
/
cdf.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
FNR == 1 {
fileindex += 1;
}
fileindex == 1 {
X[FNR] = $1;
}
ENDFILE {
if(fileindex == 1) {
asort(X);
Xi = 1;
Xn = FNR;
}
}
fileindex == 2 && FNR == 1 {
minval = $1;
if(minval >= X[1]) {
passedmin = 1;
}
}
fileindex == 2 && !passedmin && $1 > minval {
printf("%s\t%d\n", minval, FNR-1);
passedmin = 1;
}
fileindex == 2 {
while(Xi < Xn && $1 > X[Xi]) {
printf("%s\t%d\n", X[Xi], FNR-1);
Xi+=1;
}
if(Xi == Xn && $1 > X[Xi]) {
printf("%s\t%d\n", X[Xi], FNR-1);
Xi+=1;
}
last = $1;
}
END {
while(Xi <= Xn) {
printf("%s\t%d\n", X[Xi], FNR);
Xi+=1;
}
#handle case where the max element is larger than scale
if(last > X[Xn]) {
printf("%s\t%d\n", last, FNR);
}
}