Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Is there a simpler way??

by yabba (Initiate)
on Apr 08, 2001 at 07:07 UTC ( [id://70774]=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://70774]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-23 12:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found