cvs: pear /Math_Histogram Histogram3D.php Histogram4D.php
| From: | Jesus M. Castagnetto | Date: | Wed, 22 May 2002 07:14:31 +0000 |
| Subject: | cvs: pear /Math_Histogram Histogram3D.php Histogram4D.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4031@lists.php.net to get a copy of this message | ||
jmcastagnetto Wed May 22 03:14:31 2002 EDT
Modified files:
/pear/Math_Histogram Histogram3D.php Histogram4D.php
Log:
Finish adding documentation
Index: pear/Math_Histogram/Histogram3D.php diff -u pear/Math_Histogram/Histogram3D.php:1.2 pear/Math_Histogram/Histogram3D.php:1.3 --- pear/Math_Histogram/Histogram3D.php:1.2 Tue May 21 23:01:16 2002 +++ pear/Math_Histogram/Histogram3D.php Wed May 22 03:14:31 2002 @@ -16,20 +16,41 @@ // | Authors: Jesus M. Castagnetto <jmcastagnetto@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Histogram3D.php,v 1.2 2002/05/22 03:01:16 jmcastagnetto Exp $ +// $Id: Histogram3D.php,v 1.3 2002/05/22 07:14:31 jmcastagnetto Exp $ // -// Last change: Tuesday 2002-05-21 19:57:18 PDT. +// Last change: 22-May-2002. // require_once 'AbstractHistogram.php'; class Math_Histogram3D extends Math_AbstractHistogram {/*{{{*/ + /** + * Constructor for Math_Histogram3D + * + * @access public + * @param optional int $type one of HISTOGRAM_SIMPLE or HISTOGRAM_CUMMULATIVE + * @param optional array $binOptions an array of options for binning the data + * @return object Math_Histogram3D + * + * @see setBinOptions() + * @see Math_AbstractHistogram::setType() + * @see Math_AbstractHistogram + */ + function Math_Histogram3D($type=HISTOGRAM_SIMPLE,$binOptions="") {/*{{{*/ $this->setType($type); $this->setBinOptions($binOptions); }/*}}}*/ +/** + * Sets the binning options. Overrides parent's method. + * + * @access public + * @param array $binOptions an array of options for binning the data + * @return void + */ + function setBinOptions($binOptions) {/*{{{*/ if ( $this->_validBinOptions($binOptions) ) return parent::setBinOptions($binOptions); @@ -37,6 +58,19 @@ return PEAR::raiseError("incorrect options array"); }/*}}}*/ + /** + * Sets the data to be processed. The data will be validated to + * be a simple bi-dimensional numerical array + * + * @access public + * @param array $data the numeric array + * @return mixed boolean true on success, a PEAR_Error object otherwise + * + * @see _clear() + * @see Math_AbstractHistogram::getData() + * @see Math_AbstractHistogram + * @see getHistogramData() + */ function setData($data) {/*{{{*/ $this->_clear(); if (!$this->_validData($data)) @@ -53,6 +87,15 @@ return true; }/*}}}*/ + /** + * Calculates the histogram bins and frequencies + * + * @access public + * @param optional $statsMode calculate basic statistics (STATS_BASIC) or full (STATS_FULL) + * @return mixed boolean true on success, a PEAR_Error object otherwise + * + * @see Math_Stats + */ function calculate($statsMode=STATS_BASIC) {/*{{{*/ $this->_bins = array(); $this->_stats = array('x' => new Math_Stats(), 'y' => new Math_Stats()); @@ -114,6 +157,12 @@ } }/*}}}*/ + /** + * Returns the statistics for the data set + * + * @access public + * @return mixed an associative array on success, a PEAR_Error object otherwise + */ function getDataStats() {/*{{{*/ if (empty($this->_bins)) return PEAR::raiseError("histogram has not been calculated"); @@ -123,6 +172,12 @@ 'y' => $this->_stats['y']->calc($this->_statsMode)); }/*}}}*/ + /** + * Returns the statistics for the data set, filtered using the bin ranges + * + * @access public + * @return mixed an associative array on success, a PEAR_Error object otherwise + */ function getHistogramDataStats() {/*{{{*/ if (empty($this->_bins)) return PEAR::raiseError("histogram has not been calculated"); @@ -153,10 +208,25 @@ return implode("\n", $out)."\n"; }/*}}}*/ + /** + * Returns the minimum and maximum of the given unidimensional numeric + * array + * + * @access private + * @param array $elem + * @return array of values: array(min, max) + */ function _getMinMax($elem) {/*{{{*/ return array(min($this->_data[$elem]), max($this->_data[$elem])); }/*}}}*/ + /** + * Returns a subset of the bins array by bin value type + * + * @access private + * @param int $mode one of HISTOGRAM_MID_BINS, HISTOGRAM_LO_BINS or HISTOGRAM_HI_BINS + * @return array + */ function _filterBins($mode) {/*{{{*/ $map = array ( HISTOGRAM_MID_BINS => "mid", @@ -173,6 +243,17 @@ return $filtered; }/*}}}*/ + /** + * Checks that the array of options passed is valid + * Options array should have the form: + * + * $opt = array ('low'=>array('x'=>10, 'y'=>10), + * 'high'=>array(...), + * 'nbins'=>array(...)); + * + * @access private + * @return boolean + */ function _validBinOptions($binOptions) {/*{{{*/ $barray = ( is_array($binOptions) && is_array($binOptions['low']) @@ -190,6 +271,17 @@ return ($barray && $blow && $bhigh && $bnbins); }/*}}}*/ + /** + * Checks that the data passed is bi-dimensional numeric array + * of the form: + * + * $data = array ('x'=>array(...), 'y'=>array(...)); + * + * It also checks that: count($data['x']) == count($data['y']) + * + * @access private + * @return boolean + */ function _validData($data) {/*{{{*/ if (is_array($data) && is_array($data['x']) && is_array($data['y'])) { $n = count($data['x']); @@ -207,6 +299,14 @@ } }/*}}}*/ + /** + * Returns an array of data contained within the ranges for the + * histogram calculation. Overrides the empty implementation in + * Math_AbstractHistogram::_histogramData() + * + * @access private + * @return array + */ function _histogramData() {/*{{{*/ if ( $this->_rangeLow['x'] == min($this->_data['x']) && $this->_rangeHigh['x'] == max($this->_data['x']) Index: pear/Math_Histogram/Histogram4D.php diff -u pear/Math_Histogram/Histogram4D.php:1.1 pear/Math_Histogram/Histogram4D.php:1.2 --- pear/Math_Histogram/Histogram4D.php:1.1 Wed May 22 00:01:18 2002 +++ pear/Math_Histogram/Histogram4D.php Wed May 22 03:14:31 2002 @@ -16,20 +16,39 @@ // | Authors: Jesus M. Castagnetto <jmcastagnetto@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Histogram4D.php,v 1.1 2002/05/22 04:01:18 jmcastagnetto Exp $ +// $Id: Histogram4D.php,v 1.2 2002/05/22 07:14:31 jmcastagnetto Exp $ // -// Last change: Tuesday 2002-05-21 20:59:14 PDT. +// Last change: 22-May-2002. // require_once 'AbstractHistogram.php'; class Math_Histogram4D extends Math_AbstractHistogram {/*{{{*/ + /** + * Constructor for Math_Histogram4D + * + * @access public + * @param optional int $type one of HISTOGRAM_SIMPLE or HISTOGRAM_CUMMULATIVE + * @param optional array $binOptions an array of options for binning the data + * @return object Math_Histogram3D + * + * @see setBinOptions() + * @see Math_AbstractHistogram::setType() + * @see Math_AbstractHistogram + */ function Math_Histogram4D($type=HISTOGRAM_SIMPLE,$binOptions="") {/*{{{*/ $this->setType($type); $this->setBinOptions($binOptions); }/*}}}*/ + /** + * Sets the binning options. Overrides parent's method. + * + * @access public + * @param array $binOptions an array of options for binning the data + * @return void + */ function setBinOptions($binOptions) {/*{{{*/ if ( $this->_validBinOptions($binOptions) ) return parent::setBinOptions($binOptions); @@ -37,6 +56,19 @@ return PEAR::raiseError("incorrect options array"); }/*}}}*/ + /** + * Sets the data to be processed. The data will be validated to + * be a simple tri-dimensional numerical array + * + * @access public + * @param array $data the numeric array + * @return mixed boolean true on success, a PEAR_Error object otherwise + * + * @see _clear() + * @see Math_AbstractHistogram::getData() + * @see Math_AbstractHistogram + * @see getHistogramData() + */ function setData($data) {/*{{{*/ $this->_clear(); if (!$this->_validData($data)) @@ -54,6 +86,15 @@ return true; }/*}}}*/ + /** + * Calculates the histogram bins and frequencies + * + * @access public + * @param optional $statsMode calculate basic statistics (STATS_BASIC) or full (STATS_FULL) + * @return mixed boolean true on success, a PEAR_Error object otherwise + * + * @see Math_Stats + */ function calculate($statsMode=STATS_BASIC) {/*{{{*/ $this->_bins = array(); $this->_stats = array('x' => new Math_Stats(), 'y' => new Math_Stats(), 'z' => new Math_Stats()); @@ -127,6 +168,12 @@ } }/*}}}*/ + /** + * Returns the statistics for the data set + * + * @access public + * @return mixed an associative array on success, a PEAR_Error object otherwise + */ function getDataStats() {/*{{{*/ if (empty($this->_bins)) return PEAR::raiseError("histogram has not been calculated"); @@ -138,6 +185,12 @@ 'z' => $this->_stats['z']->calc($this->_statsMode)); }/*}}}*/ + /** + * Returns the statistics for the data set, filtered using the bin ranges + * + * @access public + * @return mixed an associative array on success, a PEAR_Error object otherwise + */ function getHistogramDataStats() {/*{{{*/ if (empty($this->_bins)) return PEAR::raiseError("histogram has not been calculated"); @@ -170,10 +223,25 @@ return implode("\n", $out)."\n"; }/*}}}*/ + /** + * Returns the minimum and maximum of the given unidimensional numeric + * array + * + * @access private + * @param array $elem + * @return array of values: array(min, max) + */ function _getMinMax($elem) {/*{{{*/ return array(min($this->_data[$elem]), max($this->_data[$elem])); }/*}}}*/ + /** + * Returns a subset of the bins array by bin value type + * + * @access private + * @param int $mode one of HISTOGRAM_MID_BINS, HISTOGRAM_LO_BINS or HISTOGRAM_HI_BINS + * @return array + */ function _filterBins($mode) {/*{{{*/ $map = array ( HISTOGRAM_MID_BINS => "mid", @@ -191,6 +259,18 @@ return $filtered; }/*}}}*/ + + /** + * Checks that the array of options passed is valid + * Options array should have the form: + * + * $opt = array ('low'=>array('x'=>10, 'y'=>10, 'z'=>10), + * 'high'=>array(...), + * 'nbins'=>array(...)); + * + * @access private + * @return boolean + */ function _validBinOptions($binOptions) {/*{{{*/ $barray = ( is_array($binOptions) && is_array($binOptions['low']) @@ -208,6 +288,18 @@ return ($barray && $blow && $bhigh && $bnbins); }/*}}}*/ + /** + * Checks that the data passed is tri-dimensional numeric array + * of the form: + * + * $data = array ('x'=>array(...), 'y'=>array(...), 'z'=>array(...)); + * + * It also checks that: count($data['x']) == count($data['y'] and + * count($data['x']) == count($data['z'] + * + * @access private + * @return boolean + */ function _validData($data) {/*{{{*/ if (is_array($data) && is_array($data['x']) && is_array($data['y']) && is_array($data['z'])) { $n = count($data['x']); @@ -227,6 +319,14 @@ } }/*}}}*/ + /** + * Returns an array of data contained within the ranges for the + * histogram calculation. Overrides the empty implementation in + * Math_AbstractHistogram::_histogramData() + * + * @access private + * @return array + */ function _histogramData() {/*{{{*/ if ( $this->_rangeLow['x'] == min($this->_data['x']) && $this->_rangeHigh['x'] == max($this->_data['x'])
Index: pear/Math_Histogram/Histogram3D.php diff -u pear/Math_Histogram/Histogram3D.php:1.2 pear/Math_Histogram/Histogram3D.php:1.3 --- pear/Math_Histogram/Histogram3D.php:1.2 Tue May 21 23:01:16 2002 +++ pear/Math_Histogram/Histogram3D.php Wed May 22 03:14:31 2002 @@ -16,20 +16,41 @@ // | Authors: Jesus M. Castagnetto <jmcastagnetto@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Histogram3D.php,v 1.2 2002/05/22 03:01:16 jmcastagnetto Exp $ +// $Id: Histogram3D.php,v 1.3 2002/05/22 07:14:31 jmcastagnetto Exp $ // -// Last change: Tuesday 2002-05-21 19:57:18 PDT. +// Last change: 22-May-2002. // require_once 'AbstractHistogram.php'; class Math_Histogram3D extends Math_AbstractHistogram {/*{{{*/ + /** + * Constructor for Math_Histogram3D + * + * @access public + * @param optional int $type one of HISTOGRAM_SIMPLE or HISTOGRAM_CUMMULATIVE + * @param optional array $binOptions an array of options for binning the data + * @return object Math_Histogram3D + * + * @see setBinOptions() + * @see Math_AbstractHistogram::setType() + * @see Math_AbstractHistogram + */ + function Math_Histogram3D($type=HISTOGRAM_SIMPLE,$binOptions="") {/*{{{*/ $this->setType($type); $this->setBinOptions($binOptions); }/*}}}*/ +/** + * Sets the binning options. Overrides parent's method. + * + * @access public + * @param array $binOptions an array of options for binning the data + * @return void + */ + function setBinOptions($binOptions) {/*{{{*/ if ( $this->_validBinOptions($binOptions) ) return parent::setBinOptions($binOptions); @@ -37,6 +58,19 @@ return PEAR::raiseError("incorrect options array"); }/*}}}*/ + /** + * Sets the data to be processed. The data will be validated to + * be a simple bi-dimensional numerical array + * + * @access public + * @param array $data the numeric array + * @return mixed boolean true on success, a PEAR_Error object otherwise + * + * @see _clear() + * @see Math_AbstractHistogram::getData() + * @see Math_AbstractHistogram + * @see getHistogramData() + */ function setData($data) {/*{{{*/ $this->_clear(); if (!$this->_validData($data)) @@ -53,6 +87,15 @@ return true; }/*}}}*/ + /** + * Calculates the histogram bins and frequencies + * + * @access public + * @param optional $statsMode calculate basic statistics (STATS_BASIC) or full (STATS_FULL) + * @return mixed boolean true on success, a PEAR_Error object otherwise + * + * @see Math_Stats + */ function calculate($statsMode=STATS_BASIC) {/*{{{*/ $this->_bins = array(); $this->_stats = array('x' => new Math_Stats(), 'y' => new Math_Stats()); @@ -114,6 +157,12 @@ } }/*}}}*/ + /** + * Returns the statistics for the data set + * + * @access public + * @return mixed an associative array on success, a PEAR_Error object otherwise + */ function getDataStats() {/*{{{*/ if (empty($this->_bins)) return PEAR::raiseError("histogram has not been calculated"); @@ -123,6 +172,12 @@ 'y' => $this->_stats['y']->calc($this->_statsMode)); }/*}}}*/ + /** + * Returns the statistics for the data set, filtered using the bin ranges + * + * @access public + * @return mixed an associative array on success, a PEAR_Error object otherwise + */ function getHistogramDataStats() {/*{{{*/ if (empty($this->_bins)) return PEAR::raiseError("histogram has not been calculated"); @@ -153,10 +208,25 @@ return implode("\n", $out)."\n"; }/*}}}*/ + /** + * Returns the minimum and maximum of the given unidimensional numeric + * array + * + * @access private + * @param array $elem + * @return array of values: array(min, max) + */ function _getMinMax($elem) {/*{{{*/ return array(min($this->_data[$elem]), max($this->_data[$elem])); }/*}}}*/ + /** + * Returns a subset of the bins array by bin value type + * + * @access private + * @param int $mode one of HISTOGRAM_MID_BINS, HISTOGRAM_LO_BINS or HISTOGRAM_HI_BINS + * @return array + */ function _filterBins($mode) {/*{{{*/ $map = array ( HISTOGRAM_MID_BINS => "mid", @@ -173,6 +243,17 @@ return $filtered; }/*}}}*/ + /** + * Checks that the array of options passed is valid + * Options array should have the form: + * + * $opt = array ('low'=>array('x'=>10, 'y'=>10), + * 'high'=>array(...), + * 'nbins'=>array(...)); + * + * @access private + * @return boolean + */ function _validBinOptions($binOptions) {/*{{{*/ $barray = ( is_array($binOptions) && is_array($binOptions['low']) @@ -190,6 +271,17 @@ return ($barray && $blow && $bhigh && $bnbins); }/*}}}*/ + /** + * Checks that the data passed is bi-dimensional numeric array + * of the form: + * + * $data = array ('x'=>array(...), 'y'=>array(...)); + * + * It also checks that: count($data['x']) == count($data['y']) + * + * @access private + * @return boolean + */ function _validData($data) {/*{{{*/ if (is_array($data) && is_array($data['x']) && is_array($data['y'])) { $n = count($data['x']); @@ -207,6 +299,14 @@ } }/*}}}*/ + /** + * Returns an array of data contained within the ranges for the + * histogram calculation. Overrides the empty implementation in + * Math_AbstractHistogram::_histogramData() + * + * @access private + * @return array + */ function _histogramData() {/*{{{*/ if ( $this->_rangeLow['x'] == min($this->_data['x']) && $this->_rangeHigh['x'] == max($this->_data['x']) Index: pear/Math_Histogram/Histogram4D.php diff -u pear/Math_Histogram/Histogram4D.php:1.1 pear/Math_Histogram/Histogram4D.php:1.2 --- pear/Math_Histogram/Histogram4D.php:1.1 Wed May 22 00:01:18 2002 +++ pear/Math_Histogram/Histogram4D.php Wed May 22 03:14:31 2002 @@ -16,20 +16,39 @@ // | Authors: Jesus M. Castagnetto <jmcastagnetto@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Histogram4D.php,v 1.1 2002/05/22 04:01:18 jmcastagnetto Exp $ +// $Id: Histogram4D.php,v 1.2 2002/05/22 07:14:31 jmcastagnetto Exp $ // -// Last change: Tuesday 2002-05-21 20:59:14 PDT. +// Last change: 22-May-2002. // require_once 'AbstractHistogram.php'; class Math_Histogram4D extends Math_AbstractHistogram {/*{{{*/ + /** + * Constructor for Math_Histogram4D + * + * @access public + * @param optional int $type one of HISTOGRAM_SIMPLE or HISTOGRAM_CUMMULATIVE + * @param optional array $binOptions an array of options for binning the data + * @return object Math_Histogram3D + * + * @see setBinOptions() + * @see Math_AbstractHistogram::setType() + * @see Math_AbstractHistogram + */ function Math_Histogram4D($type=HISTOGRAM_SIMPLE,$binOptions="") {/*{{{*/ $this->setType($type); $this->setBinOptions($binOptions); }/*}}}*/ + /** + * Sets the binning options. Overrides parent's method. + * + * @access public + * @param array $binOptions an array of options for binning the data + * @return void + */ function setBinOptions($binOptions) {/*{{{*/ if ( $this->_validBinOptions($binOptions) ) return parent::setBinOptions($binOptions); @@ -37,6 +56,19 @@ return PEAR::raiseError("incorrect options array"); }/*}}}*/ + /** + * Sets the data to be processed. The data will be validated to + * be a simple tri-dimensional numerical array + * + * @access public + * @param array $data the numeric array + * @return mixed boolean true on success, a PEAR_Error object otherwise + * + * @see _clear() + * @see Math_AbstractHistogram::getData() + * @see Math_AbstractHistogram + * @see getHistogramData() + */ function setData($data) {/*{{{*/ $this->_clear(); if (!$this->_validData($data)) @@ -54,6 +86,15 @@ return true; }/*}}}*/ + /** + * Calculates the histogram bins and frequencies + * + * @access public + * @param optional $statsMode calculate basic statistics (STATS_BASIC) or full (STATS_FULL) + * @return mixed boolean true on success, a PEAR_Error object otherwise + * + * @see Math_Stats + */ function calculate($statsMode=STATS_BASIC) {/*{{{*/ $this->_bins = array(); $this->_stats = array('x' => new Math_Stats(), 'y' => new Math_Stats(), 'z' => new Math_Stats()); @@ -127,6 +168,12 @@ } }/*}}}*/ + /** + * Returns the statistics for the data set + * + * @access public + * @return mixed an associative array on success, a PEAR_Error object otherwise + */ function getDataStats() {/*{{{*/ if (empty($this->_bins)) return PEAR::raiseError("histogram has not been calculated"); @@ -138,6 +185,12 @@ 'z' => $this->_stats['z']->calc($this->_statsMode)); }/*}}}*/ + /** + * Returns the statistics for the data set, filtered using the bin ranges + * + * @access public + * @return mixed an associative array on success, a PEAR_Error object otherwise + */ function getHistogramDataStats() {/*{{{*/ if (empty($this->_bins)) return PEAR::raiseError("histogram has not been calculated"); @@ -170,10 +223,25 @@ return implode("\n", $out)."\n"; }/*}}}*/ + /** + * Returns the minimum and maximum of the given unidimensional numeric + * array + * + * @access private + * @param array $elem + * @return array of values: array(min, max) + */ function _getMinMax($elem) {/*{{{*/ return array(min($this->_data[$elem]), max($this->_data[$elem])); }/*}}}*/ + /** + * Returns a subset of the bins array by bin value type + * + * @access private + * @param int $mode one of HISTOGRAM_MID_BINS, HISTOGRAM_LO_BINS or HISTOGRAM_HI_BINS + * @return array + */ function _filterBins($mode) {/*{{{*/ $map = array ( HISTOGRAM_MID_BINS => "mid", @@ -191,6 +259,18 @@ return $filtered; }/*}}}*/ + + /** + * Checks that the array of options passed is valid + * Options array should have the form: + * + * $opt = array ('low'=>array('x'=>10, 'y'=>10, 'z'=>10), + * 'high'=>array(...), + * 'nbins'=>array(...)); + * + * @access private + * @return boolean + */ function _validBinOptions($binOptions) {/*{{{*/ $barray = ( is_array($binOptions) && is_array($binOptions['low']) @@ -208,6 +288,18 @@ return ($barray && $blow && $bhigh && $bnbins); }/*}}}*/ + /** + * Checks that the data passed is tri-dimensional numeric array + * of the form: + * + * $data = array ('x'=>array(...), 'y'=>array(...), 'z'=>array(...)); + * + * It also checks that: count($data['x']) == count($data['y'] and + * count($data['x']) == count($data['z'] + * + * @access private + * @return boolean + */ function _validData($data) {/*{{{*/ if (is_array($data) && is_array($data['x']) && is_array($data['y']) && is_array($data['z'])) { $n = count($data['x']); @@ -227,6 +319,14 @@ } }/*}}}*/ + /** + * Returns an array of data contained within the ranges for the + * histogram calculation. Overrides the empty implementation in + * Math_AbstractHistogram::_histogramData() + * + * @access private + * @return array + */ function _histogramData() {/*{{{*/ if ( $this->_rangeLow['x'] == min($this->_data['x']) && $this->_rangeHigh['x'] == max($this->_data['x'])