From: <var...@us...> - 2012-12-17 15:58:35
|
Revision: 8670 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=8670&view=rev Author: vargenau Date: 2012-12-17 15:58:29 +0000 (Mon, 17 Dec 2012) Log Message: ----------- Fix mean and median calculation Modified Paths: -------------- trunk/lib/plugin/SystemInfo.php Modified: trunk/lib/plugin/SystemInfo.php =================================================================== --- trunk/lib/plugin/SystemInfo.php 2012-12-17 14:58:07 UTC (rev 8669) +++ trunk/lib/plugin/SystemInfo.php 2012-12-17 15:58:29 UTC (rev 8670) @@ -224,11 +224,8 @@ $max = max($h, $max); $min = min($h, $min); } - $median_i = (int)$n / 2; - if (!($n / 2)) - $median = $hits[$median_i]; - else - $median = $hits[$median_i]; + $mean = $n ? $sum / $n : 0; + $median = $hits[ (int)($n / 2) ]; $mintreshold = $max * $treshold / 100.0; // lower than 10% of the hits reset($hits); $nmin = $hits[0] < $mintreshold ? 1 : 0; @@ -243,7 +240,7 @@ 'sum' => $sum, 'min' => $min, 'max' => $max, - 'mean' => $sum / $n, + 'mean' => $mean, 'median' => $median, 'stddev' => stddev($hits, $sum), 'treshold' => $treshold, @@ -569,7 +566,7 @@ sort($hits); reset($hits); $n = count($hits); - $median = (int)$n / 2; + $median = (int)($n / 2); if (!($n % 2)) // proper rounding on even length return ($hits[$median] + $hits[$median - 1]) * 0.5; else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |