My statistics is a bit rusty, and tye has a better handle on what you're actually doing, but this might help. When working with statistics, you generally define a range of acceptable sample values, and any values outside of this range are discarded. These are called outliers. For example, below is your code modified to ignore the samples where po == 0, so they will not skew your results.
my $tlsamples = @series_po; # = @series_fr
my $ok_samples = 0;
my $sum_po = 0;
my $sum_fr = 0;
for (my $i; $i < $tlsamples; $i++){
# set up any conditions to skip outliers here
if($series_po[$i] == 0){
next;
}
# count & sum only good samples
$ok_samples++;
$sum_po += $series_po[$i];
$sum_fr += $series_fr[$i];
}
return 0 if ($ok_samples == 0);
$sum_fr = 1 if ($sum_fr == 0);
my $avg_po = $sum_po / $ok_samples; # =150 / 5 = 30
my $avg_fr = $sum_fr / $ok_samples; # = 10 / 5 = 2
$avg_fr = 1 (if $avg_fr == 0); # avoid div/0
my $pofr = $avg_po / $avg_fr; # = 15