diff options
Diffstat (limited to 'lin_reg1.awk')
| -rw-r--r-- | lin_reg1.awk | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lin_reg1.awk b/lin_reg1.awk index c657035..7786247 100644 --- a/lin_reg1.awk +++ b/lin_reg1.awk @@ -3,6 +3,7 @@ ### lin_reg1.awk # simple linear regression between columns + BEGIN { sign = "[+-]?" decimal = "[0-9]+[.]?[0-9]*" @@ -11,22 +12,26 @@ BEGIN { number = "^" sign "(" decimal "|" fraction ")" exponent "$" } + +# column headers NR == 1 { for (n=1; n<=NF; n++) ($n ~ number) ? header[n] = "col" n : header[n] = $n } + +# read input data NF > 0 { - if (NF > nf_max) - nf_max = NF + (NF > nf_max) ? nf_max = NF : nf_max = nf_max - ### iterate over columns + # columns for (y=1; y<=nf_max; y++) { if ($y == header[n]) continue + if ($y ~ number) { - ### mean + # mean count[y] += 1 sum[y] += $y sum2[y] += $y*$y @@ -62,6 +67,7 @@ NF > 0 { } } + END { for (y=1; y<=nf_max; y++) { for (x=1; x<=nf_max; x++) { |
