larryk has asked for the wisdom of the Perl Monks concerning the following question:
Pls comment.sub sum($) { my $listref = $_[0]; my $sum = 0; map { $sum += $_ } @{$listref}; return $sum; } sub avg($) { my $listref = $_[0]; sum($listref)/@{$listref}; } sub rms($) { my $listref = $_[0]; sqrt(sum([map{(avg($listref)-$_)**2}@{$listref}])/@{$listref}); }
"Argument is futile - you will be ignorralated!"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I get the root mean square of a list?
by davorg (Chancellor) on Jun 04, 2001 at 19:24 UTC | |
|
Re: How do I get the root mean square of a list?
by MeowChow (Vicar) on Jun 04, 2001 at 19:40 UTC | |
|
Re: How do I get the root mean square of a list?
by larryk (Friar) on Jun 04, 2001 at 20:02 UTC | |
by MeowChow (Vicar) on Jun 04, 2001 at 20:36 UTC | |
by tilly (Archbishop) on Jun 04, 2001 at 21:15 UTC | |
by princepawn (Parson) on Jun 04, 2001 at 21:16 UTC |