-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathavg_bs
executable file
·101 lines (97 loc) · 1.38 KB
/
avg_bs
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
#! /usr/bin/awk -f
function isnum(x){return(x==x+0)}
BEGIN{
if (ARGC>2)
{
print "#WARING: Average over multiple files!!";
}
if (name=="")
{
if (ARGV[1]=="")
{
print "#FILE: STDIN";
}
else
{
print "#FILE:",ARGV[1];
}
}
else
{
print "#FILE:",name,"(set by user)";
}
if (col=="")
{
col=1;
print "#Setting column to",col,"(use option \"-v col=X\" to change)";
}
else
{
print "#Using column",col,"(set by user)";
}
if (N_B=="")
{
N_B=200;
print "#Setting Number of blocks to",N_B,"(use option \"-v N_B=X\" to change)";
}
else
{
print "#Using ",N_B," blocks ";
}
if (seed=="")
{
print "#Using time as seed (use option \"-v seed=X\" to change)";
srand();
}
else
{
print "#Using ",seed," as seed";
srand(seed);
}
c=0;
warn=0;
sum=0;
sum2=0;
}
/^[@#]/{
next;
}
{
if (NF>=col&& isnum($col))
{
x[c]=$col;
c++;
sum+=$col;
sum2+=$col*$col;
}
else
{
if (warn == 0)
{
print "# Not enough data in line",NR;
warn++;
}
}
}
END{
avg=sum/c;
sum2=sum2/c;
se_n=(sum2-avg*avg)/c;
se_n=sqrt(se_n);
se_b=0;
for (b=0;b<N_B;b++){
sum=0;
for (i=0;i<c;i++){
nr=int(c*rand())
sum+=x[nr];
}
avg_b=sum/c;
se_b+=(avg_b-avg)*(avg_b-avg);
print b,avg,avg_b,se_b;
}
se_b=se_b/(N_B-1);
se_b=sqrt(se_b);
print "#Output format: avg se naiv_se values";
print avg,se_b,se_n,c;
}
#fs md5sum 68c568666ba62485a4a2f5f2ee0e5481