From 88bf411a9c885e5cb7c8edcef1c23fef87b84f0c Mon Sep 17 00:00:00 2001 From: "Jesus M. Castagnetto" Date: Fri, 16 May 2003 22:03:03 +0000 Subject: [PATCH] Fixing bug in the median calculation. Was using the n and n+1 elements instead of the n and n-1 (in a zero based array), for even number of entries. Tnxs to Jeff Hoover for the bug catching. --- Stats.php | 2 +- package.xml | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Stats.php b/Stats.php index b7ab0b5..f7d38e2 100644 --- a/Stats.php +++ b/Stats.php @@ -593,7 +593,7 @@ function median() {/*{{{*/ $n = count($arr); $h = intval($n / 2); if ($n % 2 == 0) { - $median = ($arr[$h] + $arr[$h + 1]) / 2; + $median = ($arr[$h] + $arr[$h - 1]) / 2; } else { $median = $arr[$h + 1]; } diff --git a/package.xml b/package.xml index 783f88e..214e063 100644 --- a/package.xml +++ b/package.xml @@ -26,13 +26,13 @@ PHP - 0.8.3 - 2002-05-23 + 0.8.4 + 2003-05-16 - Another bug fix release. Version 0.8.2 was not released due - to wrong tags and bugs. + Fixed problem in element selection for the calculation + of the median. Thanks to Jeff Hoover for finding this bug. - beta + stable Stats.php @@ -45,20 +45,28 @@ + + 0.8.4 + 2002-05-16 + + Fixed problem in element selection for the calculation + of the median. Thanks to Jeff Hoover for finding this bug. + + 0.8.3 2002-05-23 Another bug fix release. Version 0.8.2 was not released due - to wrong tags and bugs. + to wrong tags and bugs. - 0.8.1 + 0.8.1 2002-05-23 Bug fix in __sumdiff() and in __sumabsdev(), which made - the variance, standard deviation, etc. be calculated incorrectly. + the variance, standard deviation, etc. be calculated incorrectly.