-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbstats.awk
More file actions
executable file
·59 lines (50 loc) · 1.17 KB
/
bstats.awk
File metadata and controls
executable file
·59 lines (50 loc) · 1.17 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
#! /usr/bin/gawk -f
## Output in a nice format:
## count,min,max,sum,mean,stddev,pop_stddev
BEGIN {
OFS = ","
}
# Main section...
# The count is simply NR
{
if ( min !~ "[0-9]" )
{
min = $1
}
if ( $1 < min )
{
min = $1
}
if ( $1 >= max )
{
max = $1
}
sum += $1
delta = $1 - mean
mean += delta / NR
meansqr += delta * ( $1 - mean )
}
END {
std_dev = sqrt( meansqr / NR )
if ( NR > 1 )
{
pstd_dev = sqrt( meansqr / ( NR - 1 ) )
}
else
{
pstd_dev = 0
}
print "COUNT:\t" FNR
print "MIN:\t" min
print "MAX:\t" max
if ( sum != "no" )
{
print "SUM:\t" sum
fsum = sprintf("%'d", sum)
print "fSUM:\t" fsum
}
fmean = sprintf("%d", mean)
fstd_dev = sprintf("%d", std_dev)
print "MEAN:\t" fmean
print "STDDEV:\t" fstd_dev
}