yabba has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
(jeffa) Re: Is there a simpler way??
by jeffa (Bishop) on Apr 08, 2001 at 07:35 UTC
    You bet. It's called CPAN. Here is a solution with Statistics::Descriptive
    use strict; use Statistics::Descriptive; my $stat = Statistics::Descriptive::Full->new(); $stat->add_data(70,74,80,82,68,76); print "mean: ", $stat->mean(), "\n", "sum: ", $stat->sum(), "\n", "var: ", $stat->variance(), "\n", "dev: ", $stat->standard_deviation(), "\n";
    Of course, you won't get much credit for this solution on the test. ;)

    Jeff

    R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
    L-L--L-L--L-L--L-L--L-L--L-L--L-L--
    
Re: Is there a simpler way??
by repson (Chaplain) on Apr 08, 2001 at 07:28 UTC
    Here is one way I put together where I assume @values to already contain the data from the DAT file mentioned. Code untested.
    # compute average $total += $_ for @values; $average = $total / @values; # compute stddev according to your method $total_deviation += ($_ - $average)**2 for @values; $standard_deviation = sqrt($total_deviation) / @values; # compute stddev as I recall it, probably wrong $total_deviation += abs($_ - $average) for @values; $standard_deviation = $total_deviation / @values;
    A reply falls below the community's threshold of quality. You may see it by logging in.