Incredible oneliner
This oneliner is incredibly useful:
It calculates the average and the standard deviation of a column in a set.
I know it may sound trivial, but I didn't know that you can calculate the sd by adding the square of each term (I always calculate it by adding the square of the difference with the average).
gawk '{avg=avg+$2; sd2=sd2+($2*$2)} END{avg=avg/NR;sd2=sd2/NR; print avg" "sqrt(sd2-avg*avg)}'
It calculates the average and the standard deviation of a column in a set.
I know it may sound trivial, but I didn't know that you can calculate the sd by adding the square of each term (I always calculate it by adding the square of the difference with the average).
0 comentarios:
Publicar un comentario
Suscribirse a Enviar comentarios [Atom]
<< Inicio