Basics. Just to write it down once and for all
awk '{sum+=$1; sum2+=$1*$1} END {print sqrt(sum2/NR - (sum/NR)**2)}' file.dat
and when the above overflows due to big numbers
awk '{delta = $1 - avg; avg += delta / NR; mean2 += delta * ($1 - avg); } END { print sqrt(mean2 / NR); }' file.dat
heart commandlinefu for quick references when the iq drops at the end of the day.
No comments:
Post a Comment