summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Oetiker <tobi@oetiker.ch>2011-11-24 11:28:52 +0100
committerTobias Oetiker <tobi@oetiker.ch>2011-11-24 11:28:52 +0100
commit0f421fbf603b2427a6c010cdd375bf40b3aacabb (patch)
treebbb5787ad2963c027dadcf1ada0515db33fcf2a2
parent77890232a5020dc5caf034da9a2d1bc1392b1a3b (diff)
downloadsmokeping-0f421fbf603b2427a6c010cdd375bf40b3aacabb.tar.gz
smokeping-0f421fbf603b2427a6c010cdd375bf40b3aacabb.tar.xz
use max index instead of count ... then it all works nicely
-rw-r--r--lib/Smokeping/matchers/Median.pm5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/Smokeping/matchers/Median.pm b/lib/Smokeping/matchers/Median.pm
index 2c721bf..3973b7f 100644
--- a/lib/Smokeping/matchers/Median.pm
+++ b/lib/Smokeping/matchers/Median.pm
@@ -95,8 +95,7 @@ sub Test($$)
sub robust_median(@){
my @numbers = sort {$a <=> $b} grep { defined $_ and $_ =~ /\d/ } @_;
- my $count = scalar @numbers;
- return 0 if $count == 0;
- $count--; # we are 0 based
+ my $count = $#numbers;
+ return 0 if $count < 0;
return ($count / 2 == int($count/2)) ? $numbers[$count/2] : ($numbers[$count/2+0.5] + $numbers[$count/2-0.5])/2;
}