Article View: alt.lang.awk
Article #1Re: calculate variance of column
From: ydziO
Date: Mon, 22 Jul 2019 16:07
Date: Mon, 22 Jul 2019 16:07
25 lines
1389 bytes
1389 bytes
<voodoo.bender@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
Technical Details
Message-ID:
<5d35df2c$0$540$65785112@news.neostrada.pl>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mailReferences:
<8ea7099c-12c9-486c-b904-694d0c78ae96@googlegroups.com>Show Full Headers
Complete Article Headers
Message-ID: <5d35df2c$0$540$65785112@news.neostrada.pl> Subject: Re: calculate variance of column Date: Mon, 22 Jul 2019 16:07:08 +0000 From: ydziO <ydzio(a)hot.com> References: <8ea7099c-12c9-486c-b904-694d0c78ae96@googlegroups.com> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mail User-Agent: NewsTap/5.3.4 (iPhone/iPod Touch) Cancel-Lock: sha1:XG+eecR6zGlProCYtYfLeUvCpv8= Newsgroups: alt.lang.awk Content-Type: text/plain; charset=UTF-8 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Lines: 25 Organization: Telekomunikacja Polska Nntp-Posting-Host: 93.174.26.32 X-Trace: 1563811628 unt-rea-a-02.news.neostrada.pl 540 93.174.26.32:46713 X-Complaints-To: abuse@news.neostrada.pl