Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: A lesson in statistics

by osunderdog (Deacon)
on Mar 19, 2007 at 21:39 UTC ( #605596=note: print w/replies, xml ) Need Help??


in reply to A lesson in statistics

Perhaps something like this would work?

use strict; use Statistics::Descriptive; my $uwlRatio = 15; my $poStat = Statistics::Descriptive::Sparse->new(); my $frStat = Statistics::Descriptive::Sparse->new(); while(my $line = <DATA>) { chomp $line; my ($poData, $frData) = split( m/\s/, $line); $poStat->add_data($poData); $frStat->add_data($frData); if($poStat->mean() > 0) { my $pofrRatioMean = $poStat->mean() / $frStat->mean(); if($pofrRatioMean > $uwlRatio) { print "DANGER WILL ROBINSON! PO/FR ratio out of spec!\n"; } else { print "PO/Fr ratio within spec: $pofrRatioMean\n"; } } else { print "not enough data to calculate ratio.\n"; } } __DATA__ 0 0 0 0 150 10 0 0 200 40 210 40 220 40 220 30 220 20 220 10 220 05 220 01 220 100 220 100 2200 100 2200 2 2200 2 2200 1

With output like this:

$perl example.pl not enough data to calculate ratio. not enough data to calculate ratio. PO/Fr ratio within spec: 15 PO/Fr ratio within spec: 15 PO/Fr ratio within spec: 7 PO/Fr ratio within spec: 6.22222222222222 PO/Fr ratio within spec: 6 PO/Fr ratio within spec: 6.25 PO/Fr ratio within spec: 6.77777777777778 PO/Fr ratio within spec: 7.57894736842105 PO/Fr ratio within spec: 8.51282051282051 PO/Fr ratio within spec: 9.59183673469388 PO/Fr ratio within spec: 7.09459459459459 PO/Fr ratio within spec: 5.85858585858586 PO/Fr ratio within spec: 9.11290322580645 PO/Fr ratio within spec: 13.4939759036145 DANGER WILL ROBINSON! PO/FR ratio out of spec! DANGER WILL ROBINSON! PO/FR ratio out of spec!

Hazah! I'm Employed!

Replies are listed 'Best First'.
Re^2: A lesson in statistics
by 0xbeef (Hermit) on Mar 19, 2007 at 21:58 UTC
    Well no, since it does not provide any regard for the zero value samples. The zeroes equate to idle-ness, and should negate any quick spikes/activity.

    Thanks for pointing out Statistics::Descriptive though!

    Niel

      Umm, I'm pretty sure that's what average or mean does...

      The arithmetic mean, or mean of a set of measurements is the sum of the measurements divided by the total number of measurements.

      Further information can be found at: http://en.wikipedia.org/wiki/Arithmetic_mean

      The samples that are zero are counted, thus affecting the denominator but not the numerator.

      Hazah! I'm Employed!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://605596]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2020-12-05 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (63 votes). Check out past polls.

    Notices?