I have 3000 files (1.out, 2.out, 3.out...., each with a single column something like this:
0.446477
0.439331
0.444394
0.425003
0.428981
0.419547
0.432834
0.417874
........
I need to calculate average and standard deviation for each row across 3000 files. I could calculate the average using:
awk '{a[FNR]+=$1;b[FNR]++;}END{for(i=1;i<=FNR;i++)print a[i]/b[i];}' *.out
But I am stuck with the calculation of standard deviation.
sqrt
in awk: https://unix.stackexchange.com/a/336613/70524 – muru Aug 07 '17 at 04:56Input files
1.out
2 4 5 6
2.out
1 2 3 5
3.out
4 5 6 7
Output file should have:
(2+1+4)/3 std_dev1 (4+2+5)/3 std_dev2 (5+3+6)/3 std_dev3 (6+5+7)/3 std_dev4
– ashu Aug 07 '17 at 05:56