Skip to content

Commit

Permalink
Fixing bug in the median calculation. Was using the n and n+1 elements
Browse files Browse the repository at this point in the history
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
jmcastagnetto committed May 16, 2003
1 parent e6416ed commit 88bf411
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Stats.php
Expand Up @@ -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];
}
Expand Down
24 changes: 16 additions & 8 deletions package.xml
Expand Up @@ -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>
Expand All @@ -45,20 +45,28 @@
</filelist>
</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>
Expand Down

0 comments on commit 88bf411

Please sign in to comment.