diff options
author | Tobias Oetiker <tobi@oetiker.ch> | 2011-11-24 11:28:52 +0100 |
---|---|---|
committer | Tobias Oetiker <tobi@oetiker.ch> | 2011-11-24 11:28:52 +0100 |
commit | 0f421fbf603b2427a6c010cdd375bf40b3aacabb (patch) | |
tree | bbb5787ad2963c027dadcf1ada0515db33fcf2a2 /lib | |
parent | 77890232a5020dc5caf034da9a2d1bc1392b1a3b (diff) | |
download | smokeping-0f421fbf603b2427a6c010cdd375bf40b3aacabb.tar.gz smokeping-0f421fbf603b2427a6c010cdd375bf40b3aacabb.tar.xz |
use max index instead of count ... then it all works nicely
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Smokeping/matchers/Median.pm | 5 |
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; } |