ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
PHPExcel_Best_Fit Class Reference
+ Inheritance diagram for PHPExcel_Best_Fit:
+ Collaboration diagram for PHPExcel_Best_Fit:

Public Member Functions

 getError ()
 getBestFitType ()
 getValueOfYForX ($xValue)
 getValueOfXForY ($yValue)
 getXValues ()
 getEquation ($dp=0)
 getSlope ($dp=0)
 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 Member Functions

 _calculateGoodnessOfFit ($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const)
 _leastSquareFit ($yValues, $xValues, $const)

Protected Attributes

 $_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

Detailed Description

Definition at line 36 of file bestFitClass.php.

Constructor & Destructor Documentation

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

Reimplemented in PHPExcel_Exponential_Best_Fit, PHPExcel_Power_Best_Fit, PHPExcel_Logarithmic_Best_Fit, and PHPExcel_Linear_Best_Fit.

Definition at line 311 of file bestFitClass.php.

{
// Calculate number of points
$nY = count($yValues);
$nX = count($xValues);
// Define X Values if necessary
if ($nX == 0) {
$xValues = range(1,$nY);
$nX = $nY;
} elseif ($nY != $nX) {
// Ensure both arrays of points are the same size
$this->_error = True;
return False;
}
$this->_valueCount = $nY;
$this->_xValues = $xValues;
$this->_yValues = $yValues;
} // function __construct()

Member Function Documentation

PHPExcel_Best_Fit::_calculateGoodnessOfFit (   $sumX,
  $sumY,
  $sumX2,
  $sumY2,
  $sumXY,
  $meanX,
  $meanY,
  $const 
)
protected

Definition at line 220 of file bestFitClass.php.

References $_DFResiduals, $_valueCount, and getValueOfYForX().

Referenced by _leastSquareFit(), and PHPExcel_Polynomial_Best_Fit\_polynomial_regression().

{
$SSres = $SScov = $SScor = $SStot = $SSsex = 0.0;
foreach($this->_xValues as $xKey => $xValue) {
$bestFitY = $this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue);
$SSres += ($this->_yValues[$xKey] - $bestFitY) * ($this->_yValues[$xKey] - $bestFitY);
if ($const) {
$SStot += ($this->_yValues[$xKey] - $meanY) * ($this->_yValues[$xKey] - $meanY);
} else {
$SStot += $this->_yValues[$xKey] * $this->_yValues[$xKey];
}
$SScov += ($this->_xValues[$xKey] - $meanX) * ($this->_yValues[$xKey] - $meanY);
if ($const) {
$SSsex += ($this->_xValues[$xKey] - $meanX) * ($this->_xValues[$xKey] - $meanX);
} else {
$SSsex += $this->_xValues[$xKey] * $this->_xValues[$xKey];
}
}
$this->_SSResiduals = $SSres;
$this->_DFResiduals = $this->_valueCount - 1 - $const;
if ($this->_DFResiduals == 0.0) {
$this->_stdevOfResiduals = 0.0;
} else {
$this->_stdevOfResiduals = sqrt($SSres / $this->_DFResiduals);
}
if (($SStot == 0.0) || ($SSres == $SStot)) {
$this->_goodnessOfFit = 1;
} else {
$this->_goodnessOfFit = 1 - ($SSres / $SStot);
}
$this->_SSRegression = $this->_goodnessOfFit * $SStot;
$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->_slopeSE = $this->_stdevOfResiduals / sqrt($SSsex);
$this->_intersectSE = $this->_stdevOfResiduals * sqrt(1 / ($this->_valueCount - ($sumX * $sumX) / $sumX2));
if ($this->_SSResiduals != 0.0) {
if ($this->_DFResiduals == 0.0) {
$this->_F = 0.0;
} else {
$this->_F = $this->_SSRegression / ($this->_SSResiduals / $this->_DFResiduals);
}
} else {
if ($this->_DFResiduals == 0.0) {
$this->_F = 0.0;
} else {
$this->_F = $this->_SSRegression / $this->_DFResiduals;
}
}
} // function _calculateGoodnessOfFit()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Best_Fit::_leastSquareFit (   $yValues,
  $xValues,
  $const 
)
protected

Definition at line 274 of file bestFitClass.php.

References $_valueCount, and _calculateGoodnessOfFit().

Referenced by PHPExcel_Exponential_Best_Fit\_exponential_regression(), PHPExcel_Linear_Best_Fit\_linear_regression(), PHPExcel_Logarithmic_Best_Fit\_logarithmic_regression(), and PHPExcel_Power_Best_Fit\_power_regression().

{
// 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);
} // function _leastSquareFit()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PHPExcel_Best_Fit::getBestFitType ( )

Definition at line 86 of file bestFitClass.php.

References $_bestFitType.

{
} // function getBestFitType()
PHPExcel_Best_Fit::getCorrelation (   $dp = 0)

Definition at line 207 of file bestFitClass.php.

References $_correlation.

{
if ($dp != 0) {
return round($this->_correlation,$dp);
}
} // function getCorrelation()
PHPExcel_Best_Fit::getCovariance (   $dp = 0)

Definition at line 199 of file bestFitClass.php.

References $_covariance.

{
if ($dp != 0) {
return round($this->_covariance,$dp);
}
} // function getCovariance()
PHPExcel_Best_Fit::getDFResiduals (   $dp = 0)

Definition at line 183 of file bestFitClass.php.

References $_DFResiduals.

{
if ($dp != 0) {
return round($this->_DFResiduals,$dp);
}
} // function getDFResiduals()
PHPExcel_Best_Fit::getEquation (   $dp = 0)

Reimplemented in PHPExcel_Polynomial_Best_Fit, PHPExcel_Exponential_Best_Fit, PHPExcel_Linear_Best_Fit, PHPExcel_Logarithmic_Best_Fit, and PHPExcel_Power_Best_Fit.

Definition at line 106 of file bestFitClass.php.

{
return False;
} // function getEquation()
PHPExcel_Best_Fit::getError ( )

Definition at line 81 of file bestFitClass.php.

References $_error.

{
return $this->_error;
} // function getBestFitType()
PHPExcel_Best_Fit::getF (   $dp = 0)

Definition at line 191 of file bestFitClass.php.

References $_F.

{
if ($dp != 0) {
return round($this->_F,$dp);
}
return $this->_F;
} // function getF()
PHPExcel_Best_Fit::getGoodnessOfFit (   $dp = 0)

Definition at line 143 of file bestFitClass.php.

References $_goodnessOfFit.

Referenced by PHPExcel_Polynomial_Best_Fit\__construct().

{
if ($dp != 0) {
return round($this->_goodnessOfFit,$dp);
}
} // function getGoodnessOfFit()

+ Here is the caller graph for this function:

PHPExcel_Best_Fit::getGoodnessOfFitPercent (   $dp = 0)

Definition at line 151 of file bestFitClass.php.

{
if ($dp != 0) {
return round($this->_goodnessOfFit * 100,$dp);
}
return $this->_goodnessOfFit * 100;
} // function getGoodnessOfFitPercent()
PHPExcel_Best_Fit::getIntersectSE (   $dp = 0)

Definition at line 135 of file bestFitClass.php.

References $_intersectSE.

{
if ($dp != 0) {
return round($this->_intersectSE,$dp);
}
} // function getIntersectSE()
PHPExcel_Best_Fit::getSlopeSE (   $dp = 0)

Definition at line 119 of file bestFitClass.php.

References $_slopeSE.

{
if ($dp != 0) {
return round($this->_slopeSE,$dp);
}
} // function getSlopeSE()
PHPExcel_Best_Fit::getSSRegression (   $dp = 0)

Definition at line 167 of file bestFitClass.php.

References $_SSRegression.

{
if ($dp != 0) {
return round($this->_SSRegression,$dp);
}
} // function getSSRegression()
PHPExcel_Best_Fit::getSSResiduals (   $dp = 0)

Definition at line 175 of file bestFitClass.php.

References $_SSResiduals.

{
if ($dp != 0) {
return round($this->_SSResiduals,$dp);
}
} // function getSSResiduals()
PHPExcel_Best_Fit::getStdevOfResiduals (   $dp = 0)

Definition at line 159 of file bestFitClass.php.

References $_stdevOfResiduals.

{
if ($dp != 0) {
return round($this->_stdevOfResiduals,$dp);
}
} // function getStdevOfResiduals()
PHPExcel_Best_Fit::getValueOfXForY (   $yValue)

Reimplemented in PHPExcel_Polynomial_Best_Fit, PHPExcel_Exponential_Best_Fit, PHPExcel_Linear_Best_Fit, PHPExcel_Logarithmic_Best_Fit, and PHPExcel_Power_Best_Fit.

Definition at line 96 of file bestFitClass.php.

{
return False;
} // function getValueOfXForY()
PHPExcel_Best_Fit::getValueOfYForX (   $xValue)

Reimplemented in PHPExcel_Polynomial_Best_Fit, PHPExcel_Exponential_Best_Fit, PHPExcel_Linear_Best_Fit, PHPExcel_Logarithmic_Best_Fit, and PHPExcel_Power_Best_Fit.

Definition at line 91 of file bestFitClass.php.

Referenced by _calculateGoodnessOfFit().

{
return False;
} // function getValueOfYForX()

+ Here is the caller graph for this function:

PHPExcel_Best_Fit::getXValues ( )

Definition at line 101 of file bestFitClass.php.

References $_xValues.

{
} // function getValueOfXForY()
PHPExcel_Best_Fit::getYBestFitValues ( )

Definition at line 215 of file bestFitClass.php.

References $_yBestFitValues.

{
} // function getYBestFitValues()

Field Documentation

PHPExcel_Best_Fit::$_adjustToZero = False
protected

Definition at line 48 of file bestFitClass.php.

PHPExcel_Best_Fit::$_bestFitType = 'undetermined'
protected

Definition at line 40 of file bestFitClass.php.

Referenced by getBestFitType().

PHPExcel_Best_Fit::$_correlation = 0
protected

Definition at line 58 of file bestFitClass.php.

Referenced by getCorrelation().

PHPExcel_Best_Fit::$_covariance = 0
protected

Definition at line 56 of file bestFitClass.php.

Referenced by getCovariance().

PHPExcel_Best_Fit::$_DFResiduals = 0
protected

Definition at line 64 of file bestFitClass.php.

Referenced by _calculateGoodnessOfFit(), and getDFResiduals().

PHPExcel_Best_Fit::$_error = False
protected

Definition at line 38 of file bestFitClass.php.

Referenced by getError().

PHPExcel_Best_Fit::$_F = 0
protected

Definition at line 66 of file bestFitClass.php.

Referenced by getF().

PHPExcel_Best_Fit::$_goodnessOfFit = 1
protected

Definition at line 52 of file bestFitClass.php.

Referenced by getGoodnessOfFit().

PHPExcel_Best_Fit::$_intersect = 0
protected

Definition at line 72 of file bestFitClass.php.

Referenced by getIntersect().

PHPExcel_Best_Fit::$_intersectSE = 0
protected

Definition at line 74 of file bestFitClass.php.

Referenced by getIntersectSE().

PHPExcel_Best_Fit::$_slope = 0
protected

Definition at line 68 of file bestFitClass.php.

Referenced by PHPExcel_Polynomial_Best_Fit\getSlope(), and getSlope().

PHPExcel_Best_Fit::$_slopeSE = 0
protected

Definition at line 70 of file bestFitClass.php.

Referenced by getSlopeSE().

PHPExcel_Best_Fit::$_SSRegression = 0
protected

Definition at line 60 of file bestFitClass.php.

Referenced by getSSRegression().

PHPExcel_Best_Fit::$_SSResiduals = 0
protected

Definition at line 62 of file bestFitClass.php.

Referenced by getSSResiduals().

PHPExcel_Best_Fit::$_stdevOfResiduals = 0
protected

Definition at line 54 of file bestFitClass.php.

Referenced by getStdevOfResiduals().

PHPExcel_Best_Fit::$_valueCount = 0
protected
PHPExcel_Best_Fit::$_Xoffset = 0
protected

Definition at line 76 of file bestFitClass.php.

PHPExcel_Best_Fit::$_xValues = array()
protected

Definition at line 44 of file bestFitClass.php.

Referenced by getXValues().

PHPExcel_Best_Fit::$_yBestFitValues = array()
protected

Definition at line 50 of file bestFitClass.php.

Referenced by getYBestFitValues().

PHPExcel_Best_Fit::$_Yoffset = 0
protected

Definition at line 78 of file bestFitClass.php.

PHPExcel_Best_Fit::$_yValues = array()
protected

Definition at line 46 of file bestFitClass.php.


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