Source for file bestFitClass.php
Documentation is available at bestFitClass.php
* Copyright (c) 2006 - 2011 PHPExcel
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* @package PHPExcel_Shared_Best_Fit
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
* @package PHPExcel_Shared_Best_Fit
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
} // function getBestFitType()
} // function getBestFitType()
} // function getValueOfYForX()
} // function getValueOfXForY()
} // function getValueOfXForY()
} // function getEquation()
} // function getSlopeSE()
} // function getIntersect()
} // function getIntersectSE()
} // function getGoodnessOfFit()
} // function getGoodnessOfFitPercent()
} // function getStdevOfResiduals()
} // function getSSRegression()
} // function getSSResiduals()
} // function getDFResiduals()
public function getF($dp= 0) {
} // function getCovariance()
} // function getCorrelation()
} // function getYBestFitValues()
$SSres = $SScov = $SScor = $SStot = $SSsex = 0.0;
foreach($this->_xValues as $xKey => $xValue) {
$SSres += ($this->_yValues[$xKey] - $bestFitY) * ($this->_yValues[$xKey] - $bestFitY);
$SStot += ($this->_yValues[$xKey] - $meanY) * ($this->_yValues[$xKey] - $meanY);
$SScov += ($this->_xValues[$xKey] - $meanX) * ($this->_yValues[$xKey] - $meanY);
$SSsex += ($this->_xValues[$xKey] - $meanX) * ($this->_xValues[$xKey] - $meanX);
if (($SStot == 0.0) || ($SSres == $SStot)) {
} // function _calculateGoodnessOfFit()
$mBase = $mDivisor = $xx_sum = $xy_sum = $yy_sum = 0.0;
$xy_sum += $xValues[$i] * $yValues[$i];
$xx_sum += $xValues[$i] * $xValues[$i];
$yy_sum += $yValues[$i] * $yValues[$i];
$mBase += ($xValues[$i] - $meanX) * ($yValues[$i] - $meanY);
$mDivisor += ($xValues[$i] - $meanX) * ($xValues[$i] - $meanX);
$mBase += $xValues[$i] * $yValues[$i];
$mDivisor += $xValues[$i] * $xValues[$i];
// $this->_slope = (($this->_valueCount * $xy_sum) - ($x_sum * $y_sum)) / (($this->_valueCount * $xx_sum) - ($x_sum * $x_sum));
$this->_slope = $mBase / $mDivisor;
// $this->_intersect = ($y_sum - ($this->_slope * $x_sum)) / $this->_valueCount;
} // function _leastSquareFit()
function __construct($yValues, $xValues= array(), $const= True) {
// Calculate number of points
// Define X Values if necessary
// Ensure both arrays of points are the same size
} // function __construct()
|