Permalink
Browse files

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.
  • Loading branch information...
1 parent e6416ed commit 88bf411a9c885e5cb7c8edcef1c23fef87b84f0c @jmcastagnetto committed with May 16, 2003
Showing with 17 additions and 9 deletions.
  1. +1 −1 Stats.php
  2. +16 −8 package.xml
View
@@ -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];
}
View
@@ -26,13 +26,13 @@
<release>
<license>PHP</license>
- <version>0.8.3</version>
- <date>2002-05-23</date>
+ <version>0.8.4</version>
+ <date>2003-05-16</date>
<notes>
- 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.
</notes>
- <state>beta</state>
+ <state>stable</state>
<filelist>
<dir name="/" baseinstalldir="Math">
<file role="php">Stats.php</file>
@@ -46,19 +46,27 @@
</release>
<changelog>
<release>
+ <version>0.8.4</version>
+ <date>2002-05-16</date>
+ <notes>
+ Fixed problem in element selection for the calculation
+ of the median. Thanks to Jeff Hoover for finding this bug.
+ </notes>
+ </release>
+ <release>
<version>0.8.3</version>
<date>2002-05-23</date>
<notes>
Another bug fix release. Version 0.8.2 was not released due
- to wrong tags and bugs.
+ to wrong tags and bugs.
</notes>
</release>
<release>
- <version>0.8.1</version>
+ <version>0.8.1</version>
<date>2002-05-23</date>
<notes>
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.
</notes>
</release>
<release>

0 comments on commit 88bf411

Please sign in to comment.