ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
linearBestFitClass.php
Go to the documentation of this file.
1<?php
29require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
30
31
40{
47 protected $_bestFitType = 'linear';
48
49
56 public function getValueOfYForX($xValue) {
57 return $this->getIntersect() + $this->getSlope() * $xValue;
58 } // function getValueOfYForX()
59
60
67 public function getValueOfXForY($yValue) {
68 return ($yValue - $this->getIntersect()) / $this->getSlope();
69 } // function getValueOfXForY()
70
71
78 public function getEquation($dp=0) {
79 $slope = $this->getSlope($dp);
80 $intersect = $this->getIntersect($dp);
81
82 return 'Y = '.$intersect.' + '.$slope.' * X';
83 } // function getEquation()
84
85
93 private function _linear_regression($yValues, $xValues, $const) {
94 $this->_leastSquareFit($yValues, $xValues,$const);
95 } // function _linear_regression()
96
97
105 function __construct($yValues, $xValues=array(), $const=True) {
106 if (parent::__construct($yValues, $xValues) !== False) {
107 $this->_linear_regression($yValues, $xValues, $const);
108 }
109 } // function __construct()
110
111} // class linearBestFit
An exception for terminatinating execution or to throw for unit testing.
getIntersect($dp=0)
Return the Value of X where it intersects Y = 0.
getSlope($dp=0)
Return the Slope of the line.
_leastSquareFit($yValues, $xValues, $const)
_linear_regression($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.
__construct($yValues, $xValues=array(), $const=True)
Define the regression and calculate the goodness of fit for a set of X and Y data values.
getValueOfXForY($yValue)
Return the X-Value for a specified value of Y.
getValueOfYForX($xValue)
Return the Y-Value for a specified value of X.