4336 links
Arnaud's links
Home
Login
RSS Feed
ATOM Feed
Tag cloud
Picture wall
Daily
Links per page:
20
50
100
page 1 / 1
bash - median of column with awk - Stack Overflow
This awk program assumes one column of numerically sorted data:
#/usr/bin/env awk
{
count[NR] = $1;
}
END {
if (NR % 2) {
print count[(NR + 1) / 2];
} else {
print (count[(NR / 2)] + count[(NR / 2) + 1]) / 2.0;
}
}
Sample usage:
sort -n data_file | awk -f median.awk
August 2, 2016 at 5:33:42 PM GMT+2 *
- permalink
-
-
http://stackoverflow.com/questions/6166375/median-of-column-with-awk
awk
median
Links per page:
20
50
100
page 1 / 1