diff options
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; } |