cvs: pear /Math_Stats Stats.php
| From: | Jesus M. Castagnetto | Date: | Thu, 16 May 2002 04:27:10 +0000 |
| Subject: | cvs: pear /Math_Stats Stats.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-3848@lists.php.net to get a copy of this message | ||
jmcastagnetto Thu May 16 00:27:10 2002 EDT
Modified files:
/pear/Math_Stats Stats.php
Log:
Fixed bug with nulls and cummulative data sets
Index: pear/Math_Stats/Stats.php
diff -u pear/Math_Stats/Stats.php:1.2 pear/Math_Stats/Stats.php:1.3
--- pear/Math_Stats/Stats.php:1.2 Thu May 16 00:03:51 2002
+++ pear/Math_Stats/Stats.php Thu May 16 00:27:10 2002
@@ -16,7 +16,7 @@
// | Authors: Jesus M. Castagnetto <jmcastagnetto@php.net> |
// +----------------------------------------------------------------------+
//
-// $Id: Stats.php,v 1.2 2002/05/16 04:03:51 jmcastagnetto Exp $
+// $Id: Stats.php,v 1.3 2002/05/16 04:27:10 jmcastagnetto Exp $
//
include_once "PEAR.php";
@@ -76,13 +76,13 @@
* for example the data set:
*
* <pre>
- * $data1 = array (1,2,1,1,1,1,3,3,4,4,3,2,2,1,1,2,3,3,2,2,1,1,2,2);
+ * $data1 = array (1,2,1,1,1,1,3,3,4.1,3,2,2,4.1,1,1,2,3,3,2,2,1,1,2,2);
* </pre>
*
* can be epxressed more compactly as:
*
* <pre>
- * $data2 = array(1=>9, 2=>8, 3=>5, 4=>2);
+ * $data2 = array("1"=>9, "2"=>8, "3"=>5,
"4.1"=>2);
* </pre>
*
* Example of use:
@@ -747,13 +747,15 @@
$flag = ($this->_dataOption == STATS_DATA_CUMMULATIVE);
foreach ($this->_data as $key=>$value) {
$d = ($flag) ? $key : $value;
+ $v = ($flag) ? $value : $key;
if (!is_numeric($d)) {
switch ($this->_nullOption) {
case STATS_IGNORE_NULL :
- unset($this->_data[$key]);
+ unset($this->_data["$key"]);
break;
case STATS_USE_NULL_AS_ZERO:
- $this->_data[$key] = 0;
+ unset($this->_data["$key"]);
+ $this->_data[0] += $v;
break;
case STATS_REJECT_NULL :
default: