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!


In reply to Re: A lesson in statistics by osunderdog
in thread A lesson in statistics by 0xbeef

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.