Dear Stat Monks,

I am a fool, and strictly this problem is not perl, but lack of statistical knowledge. I apologise for that... I present the following simplest of problems:

vmstat 1 10 extract: po fr 0 0 0 0 150 10 0 0 0 0
I wish to calculate the ratio po:fr for this. If it exceeds 15:1, make some printf noise. My current solution is:

my $tlsamples = @series_po; # = @series_fr return 0 if ($tlsamples == 0); my $sum_po = sum(\@series_po); # = 150 my $sum_fr = sum(\@series_fr); # = 10 $sum_fr = 1 if ($sum_fr == 0); my $avg_po = $sum_po / $tlsamples; # =150 / 5 = 30 my $avg_fr = $sum_fr / $tlsamples; # = 10 / 5 = 2 $avg_fr = 1 (if $avg_fr == 0); # avoid div/0 my $pofr = $avg_po / $avg_fr; # = 15

This result of 15:1, is the same as for the following series:

po fr 150 10

The problem is, I need the zeroes to be significant in the first series, since they are. A single value spike should not be able to cause an alert, given many other zero values! (where 0 = no activity in vmstat context)

I have zero (pun intended) statistical background. I have thought of substituting each zero value to its nearest least-signicant alternative e.g.

po fr 150 10 1 1 1 1 1 1 1 1

In this case the ratio works out to (154/5) / (14/5) = 11. Is there a correct statistical perl-friendly approach that provides significance to the zeroes in the series?

Niel


In reply to 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.