Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing a bug with the median that I forgot to fix before

(yeah I am getting forgetful ;-)
  • Loading branch information...
commit 888ae579da8d36e3bddda9b14e6bd8bf37978437 1 parent f2c364a
@jmcastagnetto authored
Showing with 36 additions and 17 deletions.
  1. +2 −2 Stats.php
  2. +34 −15 package.xml
View
4 Stats.php
@@ -112,7 +112,7 @@
* Originally this class was part of NumPHP (Numeric PHP package)
*
* @author Jesus M. Castagnetto <jmcastagnetto@php.net>
- * @version 0.8
+ * @version 0.9
* @access public
* @package Math_Stats
*/
@@ -879,7 +879,7 @@ function median() {/*{{{*/
if ($n % 2 == 0) {
$median = ($arr[$h] + $arr[$h - 1]) / 2;
} else {
- $median = $arr[$h + 1];
+ $median = $arr[$h];
}
$this->_calculatedValues['median'] = $median;
}
View
49 package.xml
@@ -26,6 +26,40 @@
<release>
<license>PHP</license>
+ <version>0.9.0beta2</version>
+ <date>2003-06-04</date>
+ <notes>
+<![CDATA[
+This is a bug fix release. Fixes (finally) an old bug in calculation of the
+median. Users of any previous version are recommended to upgrade.
+
+When I fixed a previous bug in the calculation of the median, I forgot to apply
+the full fix, so it was calculating an erroneous value for data sets with an
+odd number of entries.
+
+Thanks to Diego Puga for pointing this out. It is good to get bug reports
+when one is getting old and forgetful. ;-)
+]]>
+ </notes>
+ <state>beta</state>
+ <filelist>
+ <dir name="/" baseinstalldir="Math">
+ <file role="php">Stats.php</file>
+ <dir name="examples" role="example">
+ <file role="php">ex_stats_simple.php</file>
+ <file role="php">ex_stats_cummulative_data.php</file>
+ </dir>
+ <dir name="test" role="test">
+ <file role="php">test_Math_Stats_instance_methods.php</file>
+ <file role="php">test_Math_Stats_instance_methods-data.php</file>
+ </dir>
+ <file role="doc">README-Math_Stats</file>
+ </dir>
+ </filelist>
+ </release>
+ <changelog>
+ <release>
+ <license>PHP</license>
<version>0.9.0beta1</version>
<date>2003-06-02</date>
<notes>
@@ -60,22 +94,7 @@ Many changes in the existing methods, and a number of new ones:
]]>
</notes>
<state>beta</state>
- <filelist>
- <dir name="/" baseinstalldir="Math">
- <file role="php">Stats.php</file>
- <dir name="examples" role="example">
- <file role="php">ex_stats_simple.php</file>
- <file role="php">ex_stats_cummulative_data.php</file>
- </dir>
- <dir name="test" role="test">
- <file role="php">instance_methods.php</file>
- <file role="php">instance_methods-data.php</file>
- </dir>
- <file role="doc">README-Math_Stats</file>
- </dir>
- </filelist>
</release>
- <changelog>
<release>
<license>PHP</license>
<version>0.8.5</version>
Please sign in to comment.
Something went wrong with that request. Please try again.