ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
PHPExcel_Polynomial_Best_Fit Class Reference
+ Inheritance diagram for PHPExcel_Polynomial_Best_Fit:
+ Collaboration diagram for PHPExcel_Polynomial_Best_Fit:

Public Member Functions

 getOrder ()
 getValueOfYForX ($xValue)
 getValueOfXForY ($yValue)
 getEquation ($dp=0)
 getSlope ($dp=0)
 getCoefficients ($dp=0)
 __construct ($order, $yValues, $xValues=array(), $const =True)
- Public Member Functions inherited from PHPExcel_Best_Fit
 getError ()
 getBestFitType ()
 getXValues ()
 getSlopeSE ($dp=0)
 getIntersect ($dp=0)
 getIntersectSE ($dp=0)
 getGoodnessOfFit ($dp=0)
 getGoodnessOfFitPercent ($dp=0)
 getStdevOfResiduals ($dp=0)
 getSSRegression ($dp=0)
 getSSResiduals ($dp=0)
 getDFResiduals ($dp=0)
 getF ($dp=0)
 getCovariance ($dp=0)
 getCorrelation ($dp=0)
 getYBestFitValues ()
 __construct ($yValues, $xValues=array(), $const =True)

Protected Attributes

 $_bestFitType = 'polynomial'
 $_order = 0
- Protected Attributes inherited from PHPExcel_Best_Fit
 $_error = False
 $_bestFitType = 'undetermined'
 $_valueCount = 0
 $_xValues = array()
 $_yValues = array()
 $_adjustToZero = False
 $_yBestFitValues = array()
 $_goodnessOfFit = 1
 $_stdevOfResiduals = 0
 $_covariance = 0
 $_correlation = 0
 $_SSRegression = 0
 $_SSResiduals = 0
 $_DFResiduals = 0
 $_F = 0
 $_slope = 0
 $_slopeSE = 0
 $_intersect = 0
 $_intersectSE = 0
 $_Xoffset = 0
 $_Yoffset = 0

Private Member Functions

 _polynomial_regression ($order, $yValues, $xValues, $const)

Additional Inherited Members

- Protected Member Functions inherited from PHPExcel_Best_Fit
 _calculateGoodnessOfFit ($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const)
 _leastSquareFit ($yValues, $xValues, $const)

Detailed Description

Definition at line 48 of file polynomialBestFitClass.php.

Constructor & Destructor Documentation

PHPExcel_Polynomial_Best_Fit::__construct (   $order,
  $yValues,
  $xValues = array(),
  $const = True 
)

Definition at line 160 of file polynomialBestFitClass.php.

References _polynomial_regression(), and PHPExcel_Best_Fit\getGoodnessOfFit().

{
if (parent::__construct($yValues, $xValues) !== False) {
if ($order < $this->_valueCount) {
$this->_bestFitType .= '_'.$order;
$this->_order = $order;
$this->_polynomial_regression($order, $yValues, $xValues, $const);
if (($this->getGoodnessOfFit() < 0.0) || ($this->getGoodnessOfFit() > 1.0)) {
$this->_error = True;
}
} else {
$this->_error = True;
}
}
} // function __construct()

+ Here is the call graph for this function:

Member Function Documentation

PHPExcel_Polynomial_Best_Fit::_polynomial_regression (   $order,
  $yValues,
  $xValues,
  $const 
)
private

Definition at line 111 of file polynomialBestFitClass.php.

References PHPExcel_Best_Fit\$_valueCount, PHPExcel_Best_Fit\_calculateGoodnessOfFit(), and getValueOfYForX().

Referenced by __construct().

{
// calculate sums
$x_sum = array_sum($xValues);
$y_sum = array_sum($yValues);
$xx_sum = $xy_sum = 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];
}
/*
* This routine uses logic from the PHP port of polyfit version 0.1
* written by Michael Bommarito and Paul Meagher
*
* The function fits a polynomial function of order $order through
* a series of x-y data points using least squares.
*
*/
for ($i = 0; $i < $this->_valueCount; ++$i) {
for ($j = 0; $j <= $order; ++$j) {
$A[$i][$j] = pow($xValues[$i], $j);
}
}
for ($i=0; $i < $this->_valueCount; ++$i) {
$B[$i] = array($yValues[$i]);
}
$matrixA = new Matrix($A);
$matrixB = new Matrix($B);
$C = $matrixA->solve($matrixB);
$coefficients = array();
for($i = 0; $i < $C->m; ++$i) {
$r = $C->get($i, 0);
if (abs($r) <= pow(10, -9)) {
$r = 0;
}
$coefficients[] = $r;
}
$this->_intersect = array_shift($coefficients);
$this->_slope = $coefficients;
$this->_calculateGoodnessOfFit($x_sum,$y_sum,$xx_sum,$yy_sum,$xy_sum);
foreach($this->_xValues as $xKey => $xValue) {
$this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue);
}
} // function _polynomial_regression()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Polynomial_Best_Fit::getCoefficients (   $dp = 0)

Definition at line 106 of file polynomialBestFitClass.php.

References PHPExcel_Best_Fit\getIntersect(), and getSlope().

{
return array_merge(array($this->getIntersect($dp)),$this->getSlope($dp));
} // function getCoefficients()

+ Here is the call graph for this function:

PHPExcel_Polynomial_Best_Fit::getEquation (   $dp = 0)

Reimplemented from PHPExcel_Best_Fit.

Definition at line 77 of file polynomialBestFitClass.php.

References $key, PHPExcel_Best_Fit\getIntersect(), and getSlope().

{
$slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp);
$equation = 'Y = '.$intersect;
foreach($slope as $key => $value) {
if ($value != 0.0) {
$equation .= ' + '.$value.' * X';
if ($key > 0) {
$equation .= '^'.($key + 1);
}
}
}
return $equation;
} // function getEquation()

+ Here is the call graph for this function:

PHPExcel_Polynomial_Best_Fit::getOrder ( )

Definition at line 55 of file polynomialBestFitClass.php.

References $_order.

{
return $this->_order;
} // function getOrder()
PHPExcel_Polynomial_Best_Fit::getSlope (   $dp = 0)

Reimplemented from PHPExcel_Best_Fit.

Definition at line 94 of file polynomialBestFitClass.php.

References PHPExcel_Best_Fit\$_slope.

Referenced by getCoefficients(), getEquation(), getValueOfXForY(), and getValueOfYForX().

{
if ($dp != 0) {
$coefficients = array();
foreach($this->_slope as $coefficient) {
$coefficients[] = round($coefficient,$dp);
}
return $coefficients;
}
return $this->_slope;
} // function getSlope()

+ Here is the caller graph for this function:

PHPExcel_Polynomial_Best_Fit::getValueOfXForY (   $yValue)

Reimplemented from PHPExcel_Best_Fit.

Definition at line 72 of file polynomialBestFitClass.php.

References PHPExcel_Best_Fit\getIntersect(), and getSlope().

{
return ($yValue - $this->getIntersect()) / $this->getSlope();
} // function getValueOfXForY()

+ Here is the call graph for this function:

PHPExcel_Polynomial_Best_Fit::getValueOfYForX (   $xValue)

Reimplemented from PHPExcel_Best_Fit.

Definition at line 60 of file polynomialBestFitClass.php.

References $key, PHPExcel_Best_Fit\getIntersect(), and getSlope().

Referenced by _polynomial_regression().

{
$retVal = $this->getIntersect();
$slope = $this->getSlope();
foreach($slope as $key => $value) {
if ($value != 0.0) {
$retVal += $value * pow($xValue, $key + 1);
}
}
return $retVal;
} // function getValueOfYForX()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

PHPExcel_Polynomial_Best_Fit::$_bestFitType = 'polynomial'
protected

Definition at line 50 of file polynomialBestFitClass.php.

PHPExcel_Polynomial_Best_Fit::$_order = 0
protected

Definition at line 52 of file polynomialBestFitClass.php.

Referenced by getOrder().


The documentation for this class was generated from the following file: