Tags

, , , , ,

Just picked this up from my favorite site: commandline-fu.

$ awk '{delta = $1 - avg; avg += delta / NR; mean2 += delta * ($1 - avg); } END { print sqrt(mean2 / NR); }'

Let’s test it by finding the standard deviation of 1, 2, 3, 4, and 5 whose standard deviation is sqrt(2): in BASH, pipe in the out put of the following (which just echoes out numbers from 1 through 5) to the above command to find that it is in fact sqrt(2) or 1.42421
$ for n in {1..5}; do echo $n; done

Advertisements