Merge branch 'psr2' into develop
This commit is contained in:
commit
0f427685bd
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Best_Fit
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
|
@ -24,14 +25,6 @@
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Best_Fit
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Shared_Trend
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Best_Fit
|
class PHPExcel_Best_Fit
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -39,89 +32,89 @@ class PHPExcel_Best_Fit
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
**/
|
**/
|
||||||
protected $_error = false;
|
protected $error = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Algorithm type to use for best-fit
|
* Algorithm type to use for best-fit
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
**/
|
**/
|
||||||
protected $_bestFitType = 'undetermined';
|
protected $bestFitType = 'undetermined';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of entries in the sets of x- and y-value arrays
|
* Number of entries in the sets of x- and y-value arrays
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
**/
|
**/
|
||||||
protected $_valueCount = 0;
|
protected $valueCount = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X-value dataseries of values
|
* X-value dataseries of values
|
||||||
*
|
*
|
||||||
* @var float[]
|
* @var float[]
|
||||||
**/
|
**/
|
||||||
protected $_xValues = array();
|
protected $xValues = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Y-value dataseries of values
|
* Y-value dataseries of values
|
||||||
*
|
*
|
||||||
* @var float[]
|
* @var float[]
|
||||||
**/
|
**/
|
||||||
protected $_yValues = array();
|
protected $yValues = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag indicating whether values should be adjusted to Y=0
|
* Flag indicating whether values should be adjusted to Y=0
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
**/
|
**/
|
||||||
protected $_adjustToZero = false;
|
protected $adjustToZero = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Y-value series of best-fit values
|
* Y-value series of best-fit values
|
||||||
*
|
*
|
||||||
* @var float[]
|
* @var float[]
|
||||||
**/
|
**/
|
||||||
protected $_yBestFitValues = array();
|
protected $yBestFitValues = array();
|
||||||
|
|
||||||
protected $_goodnessOfFit = 1;
|
protected $goodnessOfFit = 1;
|
||||||
|
|
||||||
protected $_stdevOfResiduals = 0;
|
protected $stdevOfResiduals = 0;
|
||||||
|
|
||||||
protected $_covariance = 0;
|
protected $covariance = 0;
|
||||||
|
|
||||||
protected $_correlation = 0;
|
protected $correlation = 0;
|
||||||
|
|
||||||
protected $_SSRegression = 0;
|
protected $SSRegression = 0;
|
||||||
|
|
||||||
protected $_SSResiduals = 0;
|
protected $SSResiduals = 0;
|
||||||
|
|
||||||
protected $_DFResiduals = 0;
|
protected $DFResiduals = 0;
|
||||||
|
|
||||||
protected $_F = 0;
|
protected $f = 0;
|
||||||
|
|
||||||
protected $_slope = 0;
|
protected $slope = 0;
|
||||||
|
|
||||||
protected $_slopeSE = 0;
|
protected $slopeSE = 0;
|
||||||
|
|
||||||
protected $_intersect = 0;
|
protected $intersect = 0;
|
||||||
|
|
||||||
protected $_intersectSE = 0;
|
protected $intersectSE = 0;
|
||||||
|
|
||||||
protected $_Xoffset = 0;
|
protected $xOffset = 0;
|
||||||
|
|
||||||
protected $_Yoffset = 0;
|
protected $yOffset = 0;
|
||||||
|
|
||||||
|
|
||||||
public function getError()
|
public function getError()
|
||||||
{
|
{
|
||||||
return $this->_error;
|
return $this->error;
|
||||||
} // function getBestFitType()
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getBestFitType()
|
public function getBestFitType()
|
||||||
{
|
{
|
||||||
return $this->_bestFitType;
|
return $this->bestFitType;
|
||||||
} // function getBestFitType()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Y-Value for a specified value of X
|
* Return the Y-Value for a specified value of X
|
||||||
|
@ -132,7 +125,7 @@ class PHPExcel_Best_Fit
|
||||||
public function getValueOfYForX($xValue)
|
public function getValueOfYForX($xValue)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
} // function getValueOfYForX()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the X-Value for a specified value of Y
|
* Return the X-Value for a specified value of Y
|
||||||
|
@ -143,7 +136,7 @@ class PHPExcel_Best_Fit
|
||||||
public function getValueOfXForY($yValue)
|
public function getValueOfXForY($yValue)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
} // function getValueOfXForY()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the original set of X-Values
|
* Return the original set of X-Values
|
||||||
|
@ -152,8 +145,8 @@ class PHPExcel_Best_Fit
|
||||||
*/
|
*/
|
||||||
public function getXValues()
|
public function getXValues()
|
||||||
{
|
{
|
||||||
return $this->_xValues;
|
return $this->xValues;
|
||||||
} // function getValueOfXForY()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Equation of the best-fit line
|
* Return the Equation of the best-fit line
|
||||||
|
@ -164,7 +157,7 @@ class PHPExcel_Best_Fit
|
||||||
public function getEquation($dp = 0)
|
public function getEquation($dp = 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
} // function getEquation()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Slope of the line
|
* Return the Slope of the line
|
||||||
|
@ -175,10 +168,10 @@ class PHPExcel_Best_Fit
|
||||||
public function getSlope($dp = 0)
|
public function getSlope($dp = 0)
|
||||||
{
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_slope, $dp);
|
return round($this->slope, $dp);
|
||||||
}
|
}
|
||||||
return $this->_slope;
|
return $this->slope;
|
||||||
} // function getSlope()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the standard error of the Slope
|
* Return the standard error of the Slope
|
||||||
|
@ -189,10 +182,10 @@ class PHPExcel_Best_Fit
|
||||||
public function getSlopeSE($dp = 0)
|
public function getSlopeSE($dp = 0)
|
||||||
{
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_slopeSE, $dp);
|
return round($this->slopeSE, $dp);
|
||||||
}
|
}
|
||||||
return $this->_slopeSE;
|
return $this->slopeSE;
|
||||||
} // function getSlopeSE()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Value of X where it intersects Y = 0
|
* Return the Value of X where it intersects Y = 0
|
||||||
|
@ -203,10 +196,10 @@ class PHPExcel_Best_Fit
|
||||||
public function getIntersect($dp = 0)
|
public function getIntersect($dp = 0)
|
||||||
{
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_intersect, $dp);
|
return round($this->intersect, $dp);
|
||||||
}
|
}
|
||||||
return $this->_intersect;
|
return $this->intersect;
|
||||||
} // function getIntersect()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the standard error of the Intersect
|
* Return the standard error of the Intersect
|
||||||
|
@ -217,10 +210,10 @@ class PHPExcel_Best_Fit
|
||||||
public function getIntersectSE($dp = 0)
|
public function getIntersectSE($dp = 0)
|
||||||
{
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_intersectSE, $dp);
|
return round($this->intersectSE, $dp);
|
||||||
}
|
}
|
||||||
return $this->_intersectSE;
|
return $this->intersectSE;
|
||||||
} // function getIntersectSE()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the goodness of fit for this regression
|
* Return the goodness of fit for this regression
|
||||||
|
@ -231,18 +224,18 @@ class PHPExcel_Best_Fit
|
||||||
public function getGoodnessOfFit($dp = 0)
|
public function getGoodnessOfFit($dp = 0)
|
||||||
{
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_goodnessOfFit, $dp);
|
return round($this->goodnessOfFit, $dp);
|
||||||
}
|
}
|
||||||
return $this->_goodnessOfFit;
|
return $this->goodnessOfFit;
|
||||||
} // function getGoodnessOfFit()
|
}
|
||||||
|
|
||||||
public function getGoodnessOfFitPercent($dp = 0)
|
public function getGoodnessOfFitPercent($dp = 0)
|
||||||
{
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_goodnessOfFit * 100, $dp);
|
return round($this->goodnessOfFit * 100, $dp);
|
||||||
}
|
}
|
||||||
return $this->_goodnessOfFit * 100;
|
return $this->goodnessOfFit * 100;
|
||||||
} // function getGoodnessOfFitPercent()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the standard deviation of the residuals for this regression
|
* Return the standard deviation of the residuals for this regression
|
||||||
|
@ -253,127 +246,127 @@ class PHPExcel_Best_Fit
|
||||||
public function getStdevOfResiduals($dp = 0)
|
public function getStdevOfResiduals($dp = 0)
|
||||||
{
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_stdevOfResiduals, $dp);
|
return round($this->stdevOfResiduals, $dp);
|
||||||
}
|
}
|
||||||
return $this->_stdevOfResiduals;
|
return $this->stdevOfResiduals;
|
||||||
} // function getStdevOfResiduals()
|
}
|
||||||
|
|
||||||
public function getSSRegression($dp = 0)
|
public function getSSRegression($dp = 0)
|
||||||
{
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_SSRegression, $dp);
|
return round($this->SSRegression, $dp);
|
||||||
}
|
}
|
||||||
return $this->_SSRegression;
|
return $this->SSRegression;
|
||||||
} // function getSSRegression()
|
}
|
||||||
|
|
||||||
public function getSSResiduals($dp = 0)
|
public function getSSResiduals($dp = 0)
|
||||||
{
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_SSResiduals, $dp);
|
return round($this->SSResiduals, $dp);
|
||||||
}
|
}
|
||||||
return $this->_SSResiduals;
|
return $this->SSResiduals;
|
||||||
} // function getSSResiduals()
|
}
|
||||||
|
|
||||||
public function getDFResiduals($dp = 0)
|
public function getDFResiduals($dp = 0)
|
||||||
{
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_DFResiduals, $dp);
|
return round($this->DFResiduals, $dp);
|
||||||
}
|
}
|
||||||
return $this->_DFResiduals;
|
return $this->DFResiduals;
|
||||||
} // function getDFResiduals()
|
}
|
||||||
|
|
||||||
public function getF($dp = 0)
|
public function getF($dp = 0)
|
||||||
{
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_F, $dp);
|
return round($this->f, $dp);
|
||||||
}
|
}
|
||||||
return $this->_F;
|
return $this->f;
|
||||||
} // function getF()
|
}
|
||||||
|
|
||||||
public function getCovariance($dp = 0)
|
public function getCovariance($dp = 0)
|
||||||
{
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_covariance, $dp);
|
return round($this->covariance, $dp);
|
||||||
}
|
}
|
||||||
return $this->_covariance;
|
return $this->covariance;
|
||||||
} // function getCovariance()
|
}
|
||||||
|
|
||||||
public function getCorrelation($dp = 0)
|
public function getCorrelation($dp = 0)
|
||||||
{
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_correlation, $dp);
|
return round($this->correlation, $dp);
|
||||||
}
|
}
|
||||||
return $this->_correlation;
|
return $this->correlation;
|
||||||
} // function getCorrelation()
|
}
|
||||||
|
|
||||||
public function getYBestFitValues()
|
public function getYBestFitValues()
|
||||||
{
|
{
|
||||||
return $this->_yBestFitValues;
|
return $this->yBestFitValues;
|
||||||
} // function getYBestFitValues()
|
}
|
||||||
|
|
||||||
protected function _calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const)
|
protected function calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const)
|
||||||
{
|
{
|
||||||
$SSres = $SScov = $SScor = $SStot = $SSsex = 0.0;
|
$SSres = $SScov = $SScor = $SStot = $SSsex = 0.0;
|
||||||
foreach ($this->_xValues as $xKey => $xValue) {
|
foreach ($this->xValues as $xKey => $xValue) {
|
||||||
$bestFitY = $this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue);
|
$bestFitY = $this->yBestFitValues[$xKey] = $this->getValueOfYForX($xValue);
|
||||||
|
|
||||||
$SSres += ($this->_yValues[$xKey] - $bestFitY) * ($this->_yValues[$xKey] - $bestFitY);
|
$SSres += ($this->yValues[$xKey] - $bestFitY) * ($this->yValues[$xKey] - $bestFitY);
|
||||||
if ($const) {
|
if ($const) {
|
||||||
$SStot += ($this->_yValues[$xKey] - $meanY) * ($this->_yValues[$xKey] - $meanY);
|
$SStot += ($this->yValues[$xKey] - $meanY) * ($this->yValues[$xKey] - $meanY);
|
||||||
} else {
|
} else {
|
||||||
$SStot += $this->_yValues[$xKey] * $this->_yValues[$xKey];
|
$SStot += $this->yValues[$xKey] * $this->yValues[$xKey];
|
||||||
}
|
}
|
||||||
$SScov += ($this->_xValues[$xKey] - $meanX) * ($this->_yValues[$xKey] - $meanY);
|
$SScov += ($this->xValues[$xKey] - $meanX) * ($this->yValues[$xKey] - $meanY);
|
||||||
if ($const) {
|
if ($const) {
|
||||||
$SSsex += ($this->_xValues[$xKey] - $meanX) * ($this->_xValues[$xKey] - $meanX);
|
$SSsex += ($this->xValues[$xKey] - $meanX) * ($this->xValues[$xKey] - $meanX);
|
||||||
} else {
|
} else {
|
||||||
$SSsex += $this->_xValues[$xKey] * $this->_xValues[$xKey];
|
$SSsex += $this->xValues[$xKey] * $this->xValues[$xKey];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_SSResiduals = $SSres;
|
$this->SSResiduals = $SSres;
|
||||||
$this->_DFResiduals = $this->_valueCount - 1 - $const;
|
$this->DFResiduals = $this->valueCount - 1 - $const;
|
||||||
|
|
||||||
if ($this->_DFResiduals == 0.0) {
|
if ($this->DFResiduals == 0.0) {
|
||||||
$this->_stdevOfResiduals = 0.0;
|
$this->stdevOfResiduals = 0.0;
|
||||||
} else {
|
} else {
|
||||||
$this->_stdevOfResiduals = sqrt($SSres / $this->_DFResiduals);
|
$this->stdevOfResiduals = sqrt($SSres / $this->DFResiduals);
|
||||||
}
|
}
|
||||||
if (($SStot == 0.0) || ($SSres == $SStot)) {
|
if (($SStot == 0.0) || ($SSres == $SStot)) {
|
||||||
$this->_goodnessOfFit = 1;
|
$this->goodnessOfFit = 1;
|
||||||
} else {
|
} else {
|
||||||
$this->_goodnessOfFit = 1 - ($SSres / $SStot);
|
$this->goodnessOfFit = 1 - ($SSres / $SStot);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_SSRegression = $this->_goodnessOfFit * $SStot;
|
$this->SSRegression = $this->goodnessOfFit * $SStot;
|
||||||
$this->_covariance = $SScov / $this->_valueCount;
|
$this->covariance = $SScov / $this->valueCount;
|
||||||
$this->_correlation = ($this->_valueCount * $sumXY - $sumX * $sumY) / sqrt(($this->_valueCount * $sumX2 - pow($sumX, 2)) * ($this->_valueCount * $sumY2 - pow($sumY, 2)));
|
$this->correlation = ($this->valueCount * $sumXY - $sumX * $sumY) / sqrt(($this->valueCount * $sumX2 - pow($sumX, 2)) * ($this->valueCount * $sumY2 - pow($sumY, 2)));
|
||||||
$this->_slopeSE = $this->_stdevOfResiduals / sqrt($SSsex);
|
$this->slopeSE = $this->stdevOfResiduals / sqrt($SSsex);
|
||||||
$this->_intersectSE = $this->_stdevOfResiduals * sqrt(1 / ($this->_valueCount - ($sumX * $sumX) / $sumX2));
|
$this->intersectSE = $this->stdevOfResiduals * sqrt(1 / ($this->valueCount - ($sumX * $sumX) / $sumX2));
|
||||||
if ($this->_SSResiduals != 0.0) {
|
if ($this->SSResiduals != 0.0) {
|
||||||
if ($this->_DFResiduals == 0.0) {
|
if ($this->DFResiduals == 0.0) {
|
||||||
$this->_F = 0.0;
|
$this->f = 0.0;
|
||||||
} else {
|
} else {
|
||||||
$this->_F = $this->_SSRegression / ($this->_SSResiduals / $this->_DFResiduals);
|
$this->f = $this->SSRegression / ($this->SSResiduals / $this->DFResiduals);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($this->_DFResiduals == 0.0) {
|
if ($this->DFResiduals == 0.0) {
|
||||||
$this->_F = 0.0;
|
$this->f = 0.0;
|
||||||
} else {
|
} else {
|
||||||
$this->_F = $this->_SSRegression / $this->_DFResiduals;
|
$this->f = $this->SSRegression / $this->DFResiduals;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // function _calculateGoodnessOfFit()
|
}
|
||||||
|
|
||||||
protected function _leastSquareFit($yValues, $xValues, $const)
|
protected function leastSquareFit($yValues, $xValues, $const)
|
||||||
{
|
{
|
||||||
// calculate sums
|
// calculate sums
|
||||||
$x_sum = array_sum($xValues);
|
$x_sum = array_sum($xValues);
|
||||||
$y_sum = array_sum($yValues);
|
$y_sum = array_sum($yValues);
|
||||||
$meanX = $x_sum / $this->_valueCount;
|
$meanX = $x_sum / $this->valueCount;
|
||||||
$meanY = $y_sum / $this->_valueCount;
|
$meanY = $y_sum / $this->valueCount;
|
||||||
$mBase = $mDivisor = $xx_sum = $xy_sum = $yy_sum = 0.0;
|
$mBase = $mDivisor = $xx_sum = $xy_sum = $yy_sum = 0.0;
|
||||||
for ($i = 0; $i < $this->_valueCount; ++$i) {
|
for ($i = 0; $i < $this->valueCount; ++$i) {
|
||||||
$xy_sum += $xValues[$i] * $yValues[$i];
|
$xy_sum += $xValues[$i] * $yValues[$i];
|
||||||
$xx_sum += $xValues[$i] * $xValues[$i];
|
$xx_sum += $xValues[$i] * $xValues[$i];
|
||||||
$yy_sum += $yValues[$i] * $yValues[$i];
|
$yy_sum += $yValues[$i] * $yValues[$i];
|
||||||
|
@ -388,19 +381,19 @@ class PHPExcel_Best_Fit
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate slope
|
// calculate slope
|
||||||
// $this->_slope = (($this->_valueCount * $xy_sum) - ($x_sum * $y_sum)) / (($this->_valueCount * $xx_sum) - ($x_sum * $x_sum));
|
// $this->slope = (($this->valueCount * $xy_sum) - ($x_sum * $y_sum)) / (($this->valueCount * $xx_sum) - ($x_sum * $x_sum));
|
||||||
$this->_slope = $mBase / $mDivisor;
|
$this->slope = $mBase / $mDivisor;
|
||||||
|
|
||||||
// calculate intersect
|
// calculate intersect
|
||||||
// $this->_intersect = ($y_sum - ($this->_slope * $x_sum)) / $this->_valueCount;
|
// $this->intersect = ($y_sum - ($this->slope * $x_sum)) / $this->valueCount;
|
||||||
if ($const) {
|
if ($const) {
|
||||||
$this->_intersect = $meanY - ($this->_slope * $meanX);
|
$this->intersect = $meanY - ($this->slope * $meanX);
|
||||||
} else {
|
} else {
|
||||||
$this->_intersect = 0;
|
$this->intersect = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_calculateGoodnessOfFit($x_sum, $y_sum, $xx_sum, $yy_sum, $xy_sum, $meanX, $meanY, $const);
|
$this->calculateGoodnessOfFit($x_sum, $y_sum, $xx_sum, $yy_sum, $xy_sum, $meanX, $meanY, $const);
|
||||||
} // function _leastSquareFit()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the regression
|
* Define the regression
|
||||||
|
@ -421,12 +414,12 @@ class PHPExcel_Best_Fit
|
||||||
$nX = $nY;
|
$nX = $nY;
|
||||||
} elseif ($nY != $nX) {
|
} elseif ($nY != $nX) {
|
||||||
// Ensure both arrays of points are the same size
|
// Ensure both arrays of points are the same size
|
||||||
$this->_error = true;
|
$this->error = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_valueCount = $nY;
|
$this->valueCount = $nY;
|
||||||
$this->_xValues = $xValues;
|
$this->xValues = $xValues;
|
||||||
$this->_yValues = $yValues;
|
$this->yValues = $yValues;
|
||||||
} // function __construct()
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Exponential_Best_Fit
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
|
@ -24,18 +27,6 @@
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Exponential_Best_Fit
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Shared_Trend
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +35,7 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
**/
|
**/
|
||||||
protected $_bestFitType = 'exponential';
|
protected $bestFitType = 'exponential';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Y-Value for a specified value of X
|
* Return the Y-Value for a specified value of X
|
||||||
|
@ -54,8 +45,8 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
||||||
**/
|
**/
|
||||||
public function getValueOfYForX($xValue)
|
public function getValueOfYForX($xValue)
|
||||||
{
|
{
|
||||||
return $this->getIntersect() * pow($this->getSlope(), ($xValue - $this->_Xoffset));
|
return $this->getIntersect() * pow($this->getSlope(), ($xValue - $this->xOffset));
|
||||||
} // function getValueOfYForX()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the X-Value for a specified value of Y
|
* Return the X-Value for a specified value of Y
|
||||||
|
@ -65,8 +56,8 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
||||||
**/
|
**/
|
||||||
public function getValueOfXForY($yValue)
|
public function getValueOfXForY($yValue)
|
||||||
{
|
{
|
||||||
return log(($yValue + $this->_Yoffset) / $this->getIntersect()) / log($this->getSlope());
|
return log(($yValue + $this->yOffset) / $this->getIntersect()) / log($this->getSlope());
|
||||||
} // function getValueOfXForY()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Equation of the best-fit line
|
* Return the Equation of the best-fit line
|
||||||
|
@ -79,8 +70,8 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
||||||
$slope = $this->getSlope($dp);
|
$slope = $this->getSlope($dp);
|
||||||
$intersect = $this->getIntersect($dp);
|
$intersect = $this->getIntersect($dp);
|
||||||
|
|
||||||
return 'Y = '.$intersect.' * '.$slope.'^X';
|
return 'Y = ' . $intersect . ' * ' . $slope . '^X';
|
||||||
} // function getEquation()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Slope of the line
|
* Return the Slope of the line
|
||||||
|
@ -94,7 +85,7 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
||||||
return round(exp($this->_slope), $dp);
|
return round(exp($this->_slope), $dp);
|
||||||
}
|
}
|
||||||
return exp($this->_slope);
|
return exp($this->_slope);
|
||||||
} // function getSlope()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Value of X where it intersects Y = 0
|
* Return the Value of X where it intersects Y = 0
|
||||||
|
@ -105,10 +96,10 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
||||||
public function getIntersect($dp = 0)
|
public function getIntersect($dp = 0)
|
||||||
{
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round(exp($this->_intersect), $dp);
|
return round(exp($this->intersect), $dp);
|
||||||
}
|
}
|
||||||
return exp($this->_intersect);
|
return exp($this->intersect);
|
||||||
} // function getIntersect()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the regression and calculate the goodness of fit for a set of X and Y data values
|
* Execute the regression and calculate the goodness of fit for a set of X and Y data values
|
||||||
|
@ -117,7 +108,7 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
private function _exponential_regression($yValues, $xValues, $const)
|
private function exponentialRegression($yValues, $xValues, $const)
|
||||||
{
|
{
|
||||||
foreach ($yValues as &$value) {
|
foreach ($yValues as &$value) {
|
||||||
if ($value < 0.0) {
|
if ($value < 0.0) {
|
||||||
|
@ -128,8 +119,8 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
||||||
}
|
}
|
||||||
unset($value);
|
unset($value);
|
||||||
|
|
||||||
$this->_leastSquareFit($yValues, $xValues, $const);
|
$this->leastSquareFit($yValues, $xValues, $const);
|
||||||
} // function _exponential_regression()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the regression and calculate the goodness of fit for a set of X and Y data values
|
* Define the regression and calculate the goodness of fit for a set of X and Y data values
|
||||||
|
@ -141,7 +132,7 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
||||||
public function __construct($yValues, $xValues = array(), $const = true)
|
public function __construct($yValues, $xValues = array(), $const = true)
|
||||||
{
|
{
|
||||||
if (parent::__construct($yValues, $xValues) !== false) {
|
if (parent::__construct($yValues, $xValues) !== false) {
|
||||||
$this->_exponential_regression($yValues, $xValues, $const);
|
$this->exponentialRegression($yValues, $xValues, $const);
|
||||||
}
|
}
|
||||||
} // function __construct()
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Linear_Best_Fit
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
|
@ -24,16 +27,6 @@
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Linear_Best_Fit
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Shared_Trend
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
|
class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -42,7 +35,7 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
**/
|
**/
|
||||||
protected $_bestFitType = 'linear';
|
protected $bestFitType = 'linear';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Y-Value for a specified value of X
|
* Return the Y-Value for a specified value of X
|
||||||
|
@ -53,7 +46,7 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
|
||||||
public function getValueOfYForX($xValue)
|
public function getValueOfYForX($xValue)
|
||||||
{
|
{
|
||||||
return $this->getIntersect() + $this->getSlope() * $xValue;
|
return $this->getIntersect() + $this->getSlope() * $xValue;
|
||||||
} // function getValueOfYForX()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the X-Value for a specified value of Y
|
* Return the X-Value for a specified value of Y
|
||||||
|
@ -64,7 +57,7 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
|
||||||
public function getValueOfXForY($yValue)
|
public function getValueOfXForY($yValue)
|
||||||
{
|
{
|
||||||
return ($yValue - $this->getIntersect()) / $this->getSlope();
|
return ($yValue - $this->getIntersect()) / $this->getSlope();
|
||||||
} // function getValueOfXForY()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,8 +71,8 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
|
||||||
$slope = $this->getSlope($dp);
|
$slope = $this->getSlope($dp);
|
||||||
$intersect = $this->getIntersect($dp);
|
$intersect = $this->getIntersect($dp);
|
||||||
|
|
||||||
return 'Y = '.$intersect.' + '.$slope.' * X';
|
return 'Y = ' . $intersect . ' + ' . $slope . ' * X';
|
||||||
} // function getEquation()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the regression and calculate the goodness of fit for a set of X and Y data values
|
* Execute the regression and calculate the goodness of fit for a set of X and Y data values
|
||||||
|
@ -88,10 +81,10 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
|
||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
private function _linear_regression($yValues, $xValues, $const)
|
private function linearRegression($yValues, $xValues, $const)
|
||||||
{
|
{
|
||||||
$this->_leastSquareFit($yValues, $xValues, $const);
|
$this->leastSquareFit($yValues, $xValues, $const);
|
||||||
} // function _linear_regression()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the regression and calculate the goodness of fit for a set of X and Y data values
|
* Define the regression and calculate the goodness of fit for a set of X and Y data values
|
||||||
|
@ -103,7 +96,7 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
|
||||||
public function __construct($yValues, $xValues = array(), $const = true)
|
public function __construct($yValues, $xValues = array(), $const = true)
|
||||||
{
|
{
|
||||||
if (parent::__construct($yValues, $xValues) !== false) {
|
if (parent::__construct($yValues, $xValues) !== false) {
|
||||||
$this->_linear_regression($yValues, $xValues, $const);
|
$this->linearRegression($yValues, $xValues, $const);
|
||||||
}
|
}
|
||||||
} // function __construct()
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Logarithmic_Best_Fit
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
|
@ -24,16 +27,6 @@
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Logarithmic_Best_Fit
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Shared_Trend
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -42,7 +35,7 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
**/
|
**/
|
||||||
protected $_bestFitType = 'logarithmic';
|
protected $bestFitType = 'logarithmic';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Y-Value for a specified value of X
|
* Return the Y-Value for a specified value of X
|
||||||
|
@ -52,8 +45,8 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
||||||
**/
|
**/
|
||||||
public function getValueOfYForX($xValue)
|
public function getValueOfYForX($xValue)
|
||||||
{
|
{
|
||||||
return $this->getIntersect() + $this->getSlope() * log($xValue - $this->_Xoffset);
|
return $this->getIntersect() + $this->getSlope() * log($xValue - $this->xOffset);
|
||||||
} // function getValueOfYForX()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the X-Value for a specified value of Y
|
* Return the X-Value for a specified value of Y
|
||||||
|
@ -64,7 +57,7 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
||||||
public function getValueOfXForY($yValue)
|
public function getValueOfXForY($yValue)
|
||||||
{
|
{
|
||||||
return exp(($yValue - $this->getIntersect()) / $this->getSlope());
|
return exp(($yValue - $this->getIntersect()) / $this->getSlope());
|
||||||
} // function getValueOfXForY()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Equation of the best-fit line
|
* Return the Equation of the best-fit line
|
||||||
|
@ -78,7 +71,7 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
||||||
$intersect = $this->getIntersect($dp);
|
$intersect = $this->getIntersect($dp);
|
||||||
|
|
||||||
return 'Y = '.$intersect.' + '.$slope.' * log(X)';
|
return 'Y = '.$intersect.' + '.$slope.' * log(X)';
|
||||||
} // function getEquation()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the regression and calculate the goodness of fit for a set of X and Y data values
|
* Execute the regression and calculate the goodness of fit for a set of X and Y data values
|
||||||
|
@ -87,7 +80,7 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
private function _logarithmic_regression($yValues, $xValues, $const)
|
private function logarithmicRegression($yValues, $xValues, $const)
|
||||||
{
|
{
|
||||||
foreach ($xValues as &$value) {
|
foreach ($xValues as &$value) {
|
||||||
if ($value < 0.0) {
|
if ($value < 0.0) {
|
||||||
|
@ -98,8 +91,8 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
||||||
}
|
}
|
||||||
unset($value);
|
unset($value);
|
||||||
|
|
||||||
$this->_leastSquareFit($yValues, $xValues, $const);
|
$this->leastSquareFit($yValues, $xValues, $const);
|
||||||
} // function _logarithmic_regression()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the regression and calculate the goodness of fit for a set of X and Y data values
|
* Define the regression and calculate the goodness of fit for a set of X and Y data values
|
||||||
|
@ -111,7 +104,7 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
||||||
public function __construct($yValues, $xValues = array(), $const = true)
|
public function __construct($yValues, $xValues = array(), $const = true)
|
||||||
{
|
{
|
||||||
if (parent::__construct($yValues, $xValues) !== false) {
|
if (parent::__construct($yValues, $xValues) !== false) {
|
||||||
$this->_logarithmic_regression($yValues, $xValues, $const);
|
$this->logarithmicRegression($yValues, $xValues, $const);
|
||||||
}
|
}
|
||||||
} // function __construct()
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php';
|
||||||
|
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/Matrix.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Polynomial_Best_Fit
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
|
@ -24,19 +28,6 @@
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php';
|
|
||||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/Matrix.php';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Polynomial_Best_Fit
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Shared_Trend
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -45,7 +36,7 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
**/
|
**/
|
||||||
protected $_bestFitType = 'polynomial';
|
protected $bestFitType = 'polynomial';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Polynomial order
|
* Polynomial order
|
||||||
|
@ -53,7 +44,7 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
||||||
* @protected
|
* @protected
|
||||||
* @var int
|
* @var int
|
||||||
**/
|
**/
|
||||||
protected $_order = 0;
|
protected $order = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,8 +54,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
||||||
**/
|
**/
|
||||||
public function getOrder()
|
public function getOrder()
|
||||||
{
|
{
|
||||||
return $this->_order;
|
return $this->order;
|
||||||
} // function getOrder()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +74,7 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $retVal;
|
return $retVal;
|
||||||
} // function getValueOfYForX()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,7 +86,7 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
||||||
public function getValueOfXForY($yValue)
|
public function getValueOfXForY($yValue)
|
||||||
{
|
{
|
||||||
return ($yValue - $this->getIntersect()) / $this->getSlope();
|
return ($yValue - $this->getIntersect()) / $this->getSlope();
|
||||||
} // function getValueOfXForY()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,17 +100,17 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
||||||
$slope = $this->getSlope($dp);
|
$slope = $this->getSlope($dp);
|
||||||
$intersect = $this->getIntersect($dp);
|
$intersect = $this->getIntersect($dp);
|
||||||
|
|
||||||
$equation = 'Y = '.$intersect;
|
$equation = 'Y = ' . $intersect;
|
||||||
foreach ($slope as $key => $value) {
|
foreach ($slope as $key => $value) {
|
||||||
if ($value != 0.0) {
|
if ($value != 0.0) {
|
||||||
$equation .= ' + '.$value.' * X';
|
$equation .= ' + ' . $value . ' * X';
|
||||||
if ($key > 0) {
|
if ($key > 0) {
|
||||||
$equation .= '^'.($key + 1);
|
$equation .= '^' . ($key + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $equation;
|
return $equation;
|
||||||
} // function getEquation()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,13 +129,13 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
||||||
return $coefficients;
|
return $coefficients;
|
||||||
}
|
}
|
||||||
return $this->_slope;
|
return $this->_slope;
|
||||||
} // function getSlope()
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getCoefficients($dp = 0)
|
public function getCoefficients($dp = 0)
|
||||||
{
|
{
|
||||||
return array_merge(array($this->getIntersect($dp)), $this->getSlope($dp));
|
return array_merge(array($this->getIntersect($dp)), $this->getSlope($dp));
|
||||||
} // function getCoefficients()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,13 +146,13 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
private function _polynomial_regression($order, $yValues, $xValues, $const)
|
private function polynomialRegression($order, $yValues, $xValues, $const)
|
||||||
{
|
{
|
||||||
// calculate sums
|
// calculate sums
|
||||||
$x_sum = array_sum($xValues);
|
$x_sum = array_sum($xValues);
|
||||||
$y_sum = array_sum($yValues);
|
$y_sum = array_sum($yValues);
|
||||||
$xx_sum = $xy_sum = 0;
|
$xx_sum = $xy_sum = 0;
|
||||||
for ($i = 0; $i < $this->_valueCount; ++$i) {
|
for ($i = 0; $i < $this->valueCount; ++$i) {
|
||||||
$xy_sum += $xValues[$i] * $yValues[$i];
|
$xy_sum += $xValues[$i] * $yValues[$i];
|
||||||
$xx_sum += $xValues[$i] * $xValues[$i];
|
$xx_sum += $xValues[$i] * $xValues[$i];
|
||||||
$yy_sum += $yValues[$i] * $yValues[$i];
|
$yy_sum += $yValues[$i] * $yValues[$i];
|
||||||
|
@ -174,12 +165,12 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
||||||
* a series of x-y data points using least squares.
|
* a series of x-y data points using least squares.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
for ($i = 0; $i < $this->_valueCount; ++$i) {
|
for ($i = 0; $i < $this->valueCount; ++$i) {
|
||||||
for ($j = 0; $j <= $order; ++$j) {
|
for ($j = 0; $j <= $order; ++$j) {
|
||||||
$A[$i][$j] = pow($xValues[$i], $j);
|
$A[$i][$j] = pow($xValues[$i], $j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ($i=0; $i < $this->_valueCount; ++$i) {
|
for ($i=0; $i < $this->valueCount; ++$i) {
|
||||||
$B[$i] = array($yValues[$i]);
|
$B[$i] = array($yValues[$i]);
|
||||||
}
|
}
|
||||||
$matrixA = new Matrix($A);
|
$matrixA = new Matrix($A);
|
||||||
|
@ -195,14 +186,14 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
||||||
$coefficients[] = $r;
|
$coefficients[] = $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_intersect = array_shift($coefficients);
|
$this->intersect = array_shift($coefficients);
|
||||||
$this->_slope = $coefficients;
|
$this->_slope = $coefficients;
|
||||||
|
|
||||||
$this->_calculateGoodnessOfFit($x_sum, $y_sum, $xx_sum, $yy_sum, $xy_sum);
|
$this->calculateGoodnessOfFit($x_sum, $y_sum, $xx_sum, $yy_sum, $xy_sum);
|
||||||
foreach ($this->_xValues as $xKey => $xValue) {
|
foreach ($this->xValues as $xKey => $xValue) {
|
||||||
$this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue);
|
$this->yBestFitValues[$xKey] = $this->getValueOfYForX($xValue);
|
||||||
}
|
}
|
||||||
} // function _polynomial_regression()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -216,10 +207,10 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
||||||
public function __construct($order, $yValues, $xValues = array(), $const = true)
|
public function __construct($order, $yValues, $xValues = array(), $const = true)
|
||||||
{
|
{
|
||||||
if (parent::__construct($yValues, $xValues) !== false) {
|
if (parent::__construct($yValues, $xValues) !== false) {
|
||||||
if ($order < $this->_valueCount) {
|
if ($order < $this->valueCount) {
|
||||||
$this->_bestFitType .= '_'.$order;
|
$this->bestFitType .= '_'.$order;
|
||||||
$this->_order = $order;
|
$this->order = $order;
|
||||||
$this->_polynomial_regression($order, $yValues, $xValues, $const);
|
$this->polynomialRegression($order, $yValues, $xValues, $const);
|
||||||
if (($this->getGoodnessOfFit() < 0.0) || ($this->getGoodnessOfFit() > 1.0)) {
|
if (($this->getGoodnessOfFit() < 0.0) || ($this->getGoodnessOfFit() > 1.0)) {
|
||||||
$this->_error = true;
|
$this->_error = true;
|
||||||
}
|
}
|
||||||
|
@ -227,5 +218,5 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
||||||
$this->_error = true;
|
$this->_error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // function __construct()
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Power_Best_Fit
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
|
@ -24,18 +27,6 @@
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Power_Best_Fit
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Shared_Trend
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +35,7 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
**/
|
**/
|
||||||
protected $_bestFitType = 'power';
|
protected $bestFitType = 'power';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,8 +46,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
||||||
**/
|
**/
|
||||||
public function getValueOfYForX($xValue)
|
public function getValueOfYForX($xValue)
|
||||||
{
|
{
|
||||||
return $this->getIntersect() * pow(($xValue - $this->_Xoffset), $this->getSlope());
|
return $this->getIntersect() * pow(($xValue - $this->xOffset), $this->getSlope());
|
||||||
} // function getValueOfYForX()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,8 +58,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
||||||
**/
|
**/
|
||||||
public function getValueOfXForY($yValue)
|
public function getValueOfXForY($yValue)
|
||||||
{
|
{
|
||||||
return pow((($yValue + $this->_Yoffset) / $this->getIntersect()), (1 / $this->getSlope()));
|
return pow((($yValue + $this->yOffset) / $this->getIntersect()), (1 / $this->getSlope()));
|
||||||
} // function getValueOfXForY()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,8 +73,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
||||||
$slope = $this->getSlope($dp);
|
$slope = $this->getSlope($dp);
|
||||||
$intersect = $this->getIntersect($dp);
|
$intersect = $this->getIntersect($dp);
|
||||||
|
|
||||||
return 'Y = '.$intersect.' * X^'.$slope;
|
return 'Y = ' . $intersect . ' * X^' . $slope;
|
||||||
} // function getEquation()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,10 +86,10 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
||||||
public function getIntersect($dp = 0)
|
public function getIntersect($dp = 0)
|
||||||
{
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round(exp($this->_intersect), $dp);
|
return round(exp($this->intersect), $dp);
|
||||||
}
|
}
|
||||||
return exp($this->_intersect);
|
return exp($this->intersect);
|
||||||
} // function getIntersect()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,7 +99,7 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
private function _power_regression($yValues, $xValues, $const)
|
private function powerRegression($yValues, $xValues, $const)
|
||||||
{
|
{
|
||||||
foreach ($xValues as &$value) {
|
foreach ($xValues as &$value) {
|
||||||
if ($value < 0.0) {
|
if ($value < 0.0) {
|
||||||
|
@ -127,8 +118,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
||||||
}
|
}
|
||||||
unset($value);
|
unset($value);
|
||||||
|
|
||||||
$this->_leastSquareFit($yValues, $xValues, $const);
|
$this->leastSquareFit($yValues, $xValues, $const);
|
||||||
} // function _power_regression()
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,7 +132,7 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
||||||
public function __construct($yValues, $xValues = array(), $const = true)
|
public function __construct($yValues, $xValues = array(), $const = true)
|
||||||
{
|
{
|
||||||
if (parent::__construct($yValues, $xValues) !== false) {
|
if (parent::__construct($yValues, $xValues) !== false) {
|
||||||
$this->_power_regression($yValues, $xValues, $const);
|
$this->powerRegression($yValues, $xValues, $const);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/linearBestFitClass.php';
|
||||||
|
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/logarithmicBestFitClass.php';
|
||||||
|
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/exponentialBestFitClass.php';
|
||||||
|
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/powerBestFitClass.php';
|
||||||
|
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/polynomialBestFitClass.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_trendClass
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
|
@ -24,64 +31,51 @@
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/linearBestFitClass.php';
|
|
||||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/logarithmicBestFitClass.php';
|
|
||||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/exponentialBestFitClass.php';
|
|
||||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/powerBestFitClass.php';
|
|
||||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/polynomialBestFitClass.php';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_trendClass
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Shared_Trend
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class trendClass
|
class trendClass
|
||||||
{
|
{
|
||||||
const TREND_LINEAR = 'Linear';
|
const TREND_LINEAR = 'Linear';
|
||||||
const TREND_LOGARITHMIC = 'Logarithmic';
|
const TREND_LOGARITHMIC = 'Logarithmic';
|
||||||
const TREND_EXPONENTIAL = 'Exponential';
|
const TREND_EXPONENTIAL = 'Exponential';
|
||||||
const TREND_POWER = 'Power';
|
const TREND_POWER = 'Power';
|
||||||
const TREND_POLYNOMIAL_2 = 'Polynomial_2';
|
const TREND_POLYNOMIAL_2 = 'Polynomial_2';
|
||||||
const TREND_POLYNOMIAL_3 = 'Polynomial_3';
|
const TREND_POLYNOMIAL_3 = 'Polynomial_3';
|
||||||
const TREND_POLYNOMIAL_4 = 'Polynomial_4';
|
const TREND_POLYNOMIAL_4 = 'Polynomial_4';
|
||||||
const TREND_POLYNOMIAL_5 = 'Polynomial_5';
|
const TREND_POLYNOMIAL_5 = 'Polynomial_5';
|
||||||
const TREND_POLYNOMIAL_6 = 'Polynomial_6';
|
const TREND_POLYNOMIAL_6 = 'Polynomial_6';
|
||||||
const TREND_BEST_FIT = 'Bestfit';
|
const TREND_BEST_FIT = 'Bestfit';
|
||||||
const TREND_BEST_FIT_NO_POLY = 'Bestfit_no_Polynomials';
|
const TREND_BEST_FIT_NO_POLY = 'Bestfit_no_Polynomials';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Names of the best-fit trend analysis methods
|
* Names of the best-fit trend analysis methods
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
**/
|
**/
|
||||||
private static $_trendTypes = array( self::TREND_LINEAR,
|
private static $trendTypes = array(
|
||||||
self::TREND_LOGARITHMIC,
|
self::TREND_LINEAR,
|
||||||
self::TREND_EXPONENTIAL,
|
self::TREND_LOGARITHMIC,
|
||||||
self::TREND_POWER
|
self::TREND_EXPONENTIAL,
|
||||||
);
|
self::TREND_POWER
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Names of the best-fit trend polynomial orders
|
* Names of the best-fit trend polynomial orders
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
**/
|
**/
|
||||||
private static $_trendTypePolyOrders = array( self::TREND_POLYNOMIAL_2,
|
private static $trendTypePolynomialOrders = array(
|
||||||
self::TREND_POLYNOMIAL_3,
|
self::TREND_POLYNOMIAL_2,
|
||||||
self::TREND_POLYNOMIAL_4,
|
self::TREND_POLYNOMIAL_3,
|
||||||
self::TREND_POLYNOMIAL_5,
|
self::TREND_POLYNOMIAL_4,
|
||||||
self::TREND_POLYNOMIAL_6
|
self::TREND_POLYNOMIAL_5,
|
||||||
);
|
self::TREND_POLYNOMIAL_6
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cached results for each method when trying to identify which provides the best fit
|
* Cached results for each method when trying to identify which provides the best fit
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Best_Fit[]
|
* @var PHPExcel_Best_Fit[]
|
||||||
**/
|
**/
|
||||||
private static $_trendCache = array();
|
private static $trendCache = array();
|
||||||
|
|
||||||
|
|
||||||
public static function calculate($trendType = self::TREND_BEST_FIT, $yValues, $xValues = array(), $const = true)
|
public static function calculate($trendType = self::TREND_BEST_FIT, $yValues, $xValues = array(), $const = true)
|
||||||
|
@ -107,34 +101,32 @@ class trendClass
|
||||||
case self::TREND_LOGARITHMIC:
|
case self::TREND_LOGARITHMIC:
|
||||||
case self::TREND_EXPONENTIAL:
|
case self::TREND_EXPONENTIAL:
|
||||||
case self::TREND_POWER:
|
case self::TREND_POWER:
|
||||||
if (!isset(self::$_trendCache[$key])) {
|
if (!isset(self::$trendCache[$key])) {
|
||||||
$className = 'PHPExcel_'.$trendType.'_Best_Fit';
|
$className = 'PHPExcel_'.$trendType.'_Best_Fit';
|
||||||
self::$_trendCache[$key] = new $className($yValues, $xValues, $const);
|
self::$trendCache[$key] = new $className($yValues, $xValues, $const);
|
||||||
}
|
}
|
||||||
return self::$_trendCache[$key];
|
return self::$trendCache[$key];
|
||||||
break;
|
|
||||||
case self::TREND_POLYNOMIAL_2:
|
case self::TREND_POLYNOMIAL_2:
|
||||||
case self::TREND_POLYNOMIAL_3:
|
case self::TREND_POLYNOMIAL_3:
|
||||||
case self::TREND_POLYNOMIAL_4:
|
case self::TREND_POLYNOMIAL_4:
|
||||||
case self::TREND_POLYNOMIAL_5:
|
case self::TREND_POLYNOMIAL_5:
|
||||||
case self::TREND_POLYNOMIAL_6:
|
case self::TREND_POLYNOMIAL_6:
|
||||||
if (!isset(self::$_trendCache[$key])) {
|
if (!isset(self::$trendCache[$key])) {
|
||||||
$order = substr($trendType, -1);
|
$order = substr($trendType, -1);
|
||||||
self::$_trendCache[$key] = new PHPExcel_Polynomial_Best_Fit($order, $yValues, $xValues, $const);
|
self::$trendCache[$key] = new PHPExcel_Polynomial_Best_Fit($order, $yValues, $xValues, $const);
|
||||||
}
|
}
|
||||||
return self::$_trendCache[$key];
|
return self::$trendCache[$key];
|
||||||
break;
|
|
||||||
case self::TREND_BEST_FIT:
|
case self::TREND_BEST_FIT:
|
||||||
case self::TREND_BEST_FIT_NO_POLY:
|
case self::TREND_BEST_FIT_NO_POLY:
|
||||||
// If the request is to determine the best fit regression, then we test each trend line in turn
|
// If the request is to determine the best fit regression, then we test each trend line in turn
|
||||||
// Start by generating an instance of each available trend method
|
// Start by generating an instance of each available trend method
|
||||||
foreach (self::$_trendTypes as $trendMethod) {
|
foreach (self::$trendTypes as $trendMethod) {
|
||||||
$className = 'PHPExcel_'.$trendMethod.'BestFit';
|
$className = 'PHPExcel_'.$trendMethod.'BestFit';
|
||||||
$bestFit[$trendMethod] = new $className($yValues, $xValues, $const);
|
$bestFit[$trendMethod] = new $className($yValues, $xValues, $const);
|
||||||
$bestFitValue[$trendMethod] = $bestFit[$trendMethod]->getGoodnessOfFit();
|
$bestFitValue[$trendMethod] = $bestFit[$trendMethod]->getGoodnessOfFit();
|
||||||
}
|
}
|
||||||
if ($trendType != self::TREND_BEST_FIT_NO_POLY) {
|
if ($trendType != self::TREND_BEST_FIT_NO_POLY) {
|
||||||
foreach (self::$_trendTypePolyOrders as $trendMethod) {
|
foreach (self::$trendTypePolynomialOrders as $trendMethod) {
|
||||||
$order = substr($trendMethod, -1);
|
$order = substr($trendMethod, -1);
|
||||||
$bestFit[$trendMethod] = new PHPExcel_Polynomial_Best_Fit($order, $yValues, $xValues, $const);
|
$bestFit[$trendMethod] = new PHPExcel_Polynomial_Best_Fit($order, $yValues, $xValues, $const);
|
||||||
if ($bestFit[$trendMethod]->getError()) {
|
if ($bestFit[$trendMethod]->getError()) {
|
||||||
|
@ -148,9 +140,8 @@ class trendClass
|
||||||
arsort($bestFitValue);
|
arsort($bestFitValue);
|
||||||
$bestFitType = key($bestFitValue);
|
$bestFitType = key($bestFitValue);
|
||||||
return $bestFit[$bestFitType];
|
return $bestFit[$bestFitType];
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} // function calculate()
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue