Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

calculate variance of column

5 views
Skip to first unread message

voodoo...@gmail.com

unread,
Nov 29, 2018, 8:44:53 AM11/29/18
to
Hi,
I'm trying to elabotare a script to calulate variance of column of values skip first row

awk 'NR>1''{ s += $2 } END { print "sum: ", s, " average: ", s/(NR-1), " variance: ", 1 / ((NR-1) - 1) * sum($2- s/(NR-1))^2, " samples: ", (NR-1) }'

I obtain error
fatal: `sum 'function not defined

regards

Al

Unknown

unread,
Jul 22, 2019, 12:07:11 PM7/22/19
to
<voodoo...@gmail.com> wrote:
> Hi,
> I'm trying to elabotare a script to calulate variance of column of values skip first row
>
> awk 'NR>1''{ s += $2 } END { print "sum: ", s, " average: ",), "
> variance: ", 1 / ((NR-1) - 1) * sum($2- s/(NR-1))^2, " samples: ", (NR-1) }'
>
> I obtain error
> fatal: `sum 'function not defined
>
> regards
>
> Al
>

Here: is error


sum($2- s/(NR-1)

If you want sum so You have to do like this

s/(NR-1)

replace divide by this "+" -without quotation marks
0 new messages