Cumulative standard deviation: Difference between revisions

→‎{{header|Perl}}: shorter perl version
(Added two other solutions: one using an accumulator object, the other using a closure.)
(→‎{{header|Perl}}: shorter perl version)
Line 2,982:
0.866025403784439
0.979795897113272
1
1.39970842444753
2</pre>
 
one-liner:
<lang bash>perl -MMath::StdDev -e '$d=new Math::StdDev;foreach my $v ( 2,4,4,4,5,5,7,9 ) {$d->Update($v); print $d->variance(),"\n"}'</lang>
 
small script:
<lang perl>use Math::StdDev;
$d=new Math::StdDev;
foreach my $v ( 2,4,4,4,5,5,7,9 ) {
$d->Update($v);
print $d->variance(),"\n"
}</lang>
 
{{out}}
<pre>
0
1
0.942809041582063
0.866025403784439
0.979795897113271
1
1.39970842444753
Anonymous user