2679 |
18 Sep 14 |
nicklas |
#!/bin/awk -f |
2679 |
18 Sep 14 |
nicklas |
2 |
|
2679 |
18 Sep 14 |
nicklas |
# Jari Häkkinen, September 2014 |
2679 |
18 Sep 14 |
nicklas |
4 |
|
2679 |
18 Sep 14 |
nicklas |
BEGIN { |
2679 |
18 Sep 14 |
nicklas |
FS="\t"; |
2679 |
18 Sep 14 |
nicklas |
mean=0; |
2679 |
18 Sep 14 |
nicklas |
m2=0; |
2679 |
18 Sep 14 |
nicklas |
n=0; |
2679 |
18 Sep 14 |
nicklas |
10 |
} |
2679 |
18 Sep 14 |
nicklas |
11 |
|
2679 |
18 Sep 14 |
nicklas |
12 |
{ |
6378 |
10 Sep 21 |
nicklas |
d=$9 < 0 ? -$9 : $9; |
2679 |
18 Sep 14 |
nicklas |
if ((d>0) && (d<500)) { |
2679 |
18 Sep 14 |
nicklas |
mean+=d; |
2679 |
18 Sep 14 |
nicklas |
m2+=d*d |
2679 |
18 Sep 14 |
nicklas |
n++; |
2679 |
18 Sep 14 |
nicklas |
18 |
} |
2679 |
18 Sep 14 |
nicklas |
19 |
} |
2679 |
18 Sep 14 |
nicklas |
20 |
|
2679 |
18 Sep 14 |
nicklas |
END { |
2679 |
18 Sep 14 |
nicklas |
mean/=n; |
2679 |
18 Sep 14 |
nicklas |
variance=(m2-n*mean*mean)/(n-1); |
2679 |
18 Sep 14 |
nicklas |
std=sqrt(variance); |
6378 |
10 Sep 21 |
nicklas |
n/=2; |
2679 |
18 Sep 14 |
nicklas |
# printf("N: %g\n",n); |
2679 |
18 Sep 14 |
nicklas |
# printf("Mean: %g\n",mean); |
2679 |
18 Sep 14 |
nicklas |
# printf("Variance: %g\n",variance); |
2679 |
18 Sep 14 |
nicklas |
# printf("std: %g\n",std); |
2830 |
17 Oct 14 |
jari |
printf("%ld\t%g\t%g\n",n,mean,std); |
2679 |
18 Sep 14 |
nicklas |
31 |
} |