29require_once PHPEXCEL_ROOT . 
'PHPExcel/Shared/trend/bestFitClass.php';
 
   30require_once PHPEXCEL_ROOT . 
'PHPExcel/Shared/JAMA/Matrix.php';
 
   78                foreach($slope as 
$key => $value) {
 
   80                                $retVal += $value * pow($xValue, 
$key + 1);
 
  108                $equation = 
'Y = '.$intersect;
 
  109                foreach($slope as 
$key => $value) {
 
  111                                $equation .= 
' + '.$value.
' * X';
 
  113                                        $equation .= 
'^'.($key + 1);
 
  129                        $coefficients = array();
 
  130                        foreach($this->_slope as $coefficient) {
 
  131                                $coefficients[] = round($coefficient,$dp);
 
  133                        return $coefficients;
 
  154                $x_sum = array_sum($xValues);
 
  155                $y_sum = array_sum($yValues);
 
  156                $xx_sum = $xy_sum = 0;
 
  158                        $xy_sum += $xValues[
$i] * $yValues[
$i];
 
  159                        $xx_sum += $xValues[
$i] * $xValues[
$i];
 
  160                        $yy_sum += $yValues[
$i] * $yValues[
$i];
 
  171                        for ($j = 0; $j <= $order; ++$j) {
 
  172                                $A[
$i][$j] = pow($xValues[
$i], $j);
 
  176                        $B[
$i] = array($yValues[
$i]);
 
  178                $matrixA = 
new Matrix($A);
 
  179                $matrixB = 
new Matrix($B);
 
  180                $C = $matrixA->solve($matrixB);
 
  182                $coefficients = array();
 
  183                for(
$i = 0; 
$i < $C->m; ++
$i) {
 
  185                        if (abs(
$r) <= pow(10, -9)) {
 
  188                        $coefficients[] = 
$r;
 
  191                $this->_intersect = array_shift($coefficients);
 
  192                $this->_slope = $coefficients;
 
  195                foreach($this->_xValues as $xKey => $xValue) {
 
  209        function __construct($order, $yValues, $xValues=array(), $const=True) {
 
  210                if (parent::__construct($yValues, $xValues) !== False) {
 
  211                        if ($order < $this->_valueCount) {
 
  212                                $this->_bestFitType .= 
'_'.$order;
 
  213                                $this->_order = $order;
 
  216                                        $this->_error = True;
 
  219                                $this->_error = True;
 
An exception for terminatinating execution or to throw for unit testing.
getGoodnessOfFit($dp=0)
Return the goodness of fit for this regression.
getIntersect($dp=0)
Return the Value of X where it intersects Y = 0.
_calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const)
getValueOfXForY($yValue)
Return the X-Value for a specified value of Y.
__construct($order, $yValues, $xValues=array(), $const=True)
Define the regression and calculate the goodness of fit for a set of X and Y data values.
getSlope($dp=0)
Return the Slope of the line.
getOrder()
Return the order of this polynomial.
getValueOfYForX($xValue)
Return the Y-Value for a specified value of X.
_polynomial_regression($order, $yValues, $xValues, $const)
Execute the regression and calculate the goodness of fit for a set of X and Y data values.
getEquation($dp=0)
Return the Equation of the best-fit line.