hi!
i have a file like the attachement.
you can see on the last column, there is a marker from 1 to 64 for each time.
I'd like to have the median for each marker: i want to get a median every 128 values
the result is : for an hour and marker x, i have the median value
thank you for your help!
otheus
January 27, 2009, 8:59am
2
By "median", do you mean this ?
By "every 128 values", do you mean every 128 lines? And do you want the median for each set of 128 lines, as opposed to the running median?
Assuming yes... and you have gawk
gawk -v max=128 '
function median(c,v, j) {
asort(v,j);
if (c % 2) return j[(c+1)/2];
else return (j[c/2+1]+j[c/2])/2.0;
}
{
count++;values[count]=$NF;
if (count >= max) {
print median(count,values); count=0;
}
}
END {
print median(count,values);
}'
i use awk
that's the good link for median.
in fact, i want the median of each set of 128 lines
your script does that?
otheus
January 27, 2009, 11:10am
4
yep. i think so. I tested it on sets of 10 instead of 128 and it seemed to work correctly.
excuse me
i'm a newbie, but how can i use it with the input file?
sorry for my question.
sorry!!
no need to answer!!
many thanks!!!!