protected function PHPExcel_Best_Fit::_leastSquareFit in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Shared/trend/bestFitClass.php \PHPExcel_Best_Fit::_leastSquareFit()
4 calls to PHPExcel_Best_Fit::_leastSquareFit()
- PHPExcel_Exponential_Best_Fit::_exponential_regression in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ trend/ exponentialBestFitClass.php - * Execute the regression and calculate the goodness of fit for a set of X and Y data values * *
- PHPExcel_Linear_Best_Fit::_linear_regression in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ trend/ linearBestFitClass.php - * Execute the regression and calculate the goodness of fit for a set of X and Y data values * *
- PHPExcel_Logarithmic_Best_Fit::_logarithmic_regression in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ trend/ logarithmicBestFitClass.php - * Execute the regression and calculate the goodness of fit for a set of X and Y data values * *
- PHPExcel_Power_Best_Fit::_power_regression in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ trend/ powerBestFitClass.php - * Execute the regression and calculate the goodness of fit for a set of X and Y data values * *
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Shared/ trend/ bestFitClass.php, line 368
Class
- PHPExcel_Best_Fit
- PHPExcel_Best_Fit
Code
protected function _leastSquareFit($yValues, $xValues, $const) {
// calculate sums
$x_sum = array_sum($xValues);
$y_sum = array_sum($yValues);
$meanX = $x_sum / $this->_valueCount;
$meanY = $y_sum / $this->_valueCount;
$mBase = $mDivisor = $xx_sum = $xy_sum = $yy_sum = 0.0;
for ($i = 0; $i < $this->_valueCount; ++$i) {
$xy_sum += $xValues[$i] * $yValues[$i];
$xx_sum += $xValues[$i] * $xValues[$i];
$yy_sum += $yValues[$i] * $yValues[$i];
if ($const) {
$mBase += ($xValues[$i] - $meanX) * ($yValues[$i] - $meanY);
$mDivisor += ($xValues[$i] - $meanX) * ($xValues[$i] - $meanX);
}
else {
$mBase += $xValues[$i] * $yValues[$i];
$mDivisor += $xValues[$i] * $xValues[$i];
}
}
// calculate slope
// $this->_slope = (($this->_valueCount * $xy_sum) - ($x_sum * $y_sum)) / (($this->_valueCount * $xx_sum) - ($x_sum * $x_sum));
$this->_slope = $mBase / $mDivisor;
// calculate intersect
// $this->_intersect = ($y_sum - ($this->_slope * $x_sum)) / $this->_valueCount;
if ($const) {
$this->_intersect = $meanY - $this->_slope * $meanX;
}
else {
$this->_intersect = 0;
}
$this
->_calculateGoodnessOfFit($x_sum, $y_sum, $xx_sum, $yy_sum, $xy_sum, $meanX, $meanY, $const);
}