I have a data looks like:
condition A
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
then I calculated the mean value of this condition is 0.875 by using a awk command as below: (basically it's just sum all value divided by number of row)
Mean: cat $a.csv | awk -F"," '$1=="Picture" && $2=="1" && $3=="hit" && $4==1{c++} END {print c/16}'
My question is how to calculate standard deviation of this condition? I already know SD of this condition is 0.3415650255 calculated by EXCEL...
And I already tried out several awk commands but still cannot get this result right...
cat $a.csv | awk -F"," '$1=="Picture" && $2=="2" && $3=="hit" && $4=="2"{c++} END {c=0;ssq=0;for (i=1;i<=16;i++){c+=$i;ssq+=$i**2}; print (ssq/16-(c/16)**2)**0.5}'
cat $a.csv | awk -F"," '$1=="Picture" && $2=="2" && $3=="hit" && $4==2{c++} {delta=$4-(c/16); avg==delta/16;mean2+=delta*($4-avg);} END { avg=c/16; printf "mean: %f. standard deviation: %f \n", avg, sqrt(mean2/16) }'
cat $a.csv | awk -F"," '$1=="Picture" && $2=="2" && $3=="hit" && $4==2{c++} END { avg=c/16; printf "mean: %f. standard deviation: %f \n", avg, sqrt((c/16-1)-(c/16-1)^2) }'
I still cannot get the right standard deviation in this condition. Does anyone know where is the problem?