I want to compute the variance of an input txt file like this one:
1, 5
2, 5
3, 5
4, 10
And I want the output to be like:
1, 0
2, 0
3, 0
4, 4.6875
I've used this line:
awk '{c[NR]=$2; s=s+c[NR]; avg= s / NR; var=var+(($2 - avg)^2 / (NR )); print var }' inputfile > outputfile
Standard deviation formula is described in http://www.mathsisfun.com/data/standard-deviation.html
So basically you need to say:
Doing it in your sample input:
So in
awk
we can say:Test