ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
powerBestFitClass.php
Go to the documentation of this file.
1 <?php
29 require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php';
30 
31 
40 {
47  protected $_bestFitType = 'power';
48 
49 
56  public function getValueOfYForX($xValue) {
57  return $this->getIntersect() * pow(($xValue - $this->_Xoffset),$this->getSlope());
58  } // function getValueOfYForX()
59 
60 
67  public function getValueOfXForY($yValue) {
68  return pow((($yValue + $this->_Yoffset) / $this->getIntersect()),(1 / $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.' * X^'.$slope;
83  } // function getEquation()
84 
85 
92  public function getIntersect($dp=0) {
93  if ($dp != 0) {
94  return round(exp($this->_intersect),$dp);
95  }
96  return exp($this->_intersect);
97  } // function getIntersect()
98 
99 
107  private function _power_regression($yValues, $xValues, $const) {
108  foreach($xValues as &$value) {
109  if ($value < 0.0) {
110  $value = 0 - log(abs($value));
111  } elseif ($value > 0.0) {
112  $value = log($value);
113  }
114  }
115  unset($value);
116  foreach($yValues as &$value) {
117  if ($value < 0.0) {
118  $value = 0 - log(abs($value));
119  } elseif ($value > 0.0) {
120  $value = log($value);
121  }
122  }
123  unset($value);
124 
125  $this->_leastSquareFit($yValues, $xValues, $const);
126  } // function _power_regression()
127 
128 
136  function __construct($yValues, $xValues=array(), $const=True) {
137  if (parent::__construct($yValues, $xValues) !== False) {
138  $this->_power_regression($yValues, $xValues, $const);
139  }
140  } // function __construct()
141 
142 } // class powerBestFit
getIntersect($dp=0)
Return the Value of X where it intersects Y = 0.
getValueOfYForX($xValue)
Return the Y-Value for a specified value of X.
_power_regression($yValues, $xValues, $const)
Execute 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.
getEquation($dp=0)
Return the Equation of the best-fit line.
Create styles array
The data for the language used.
__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.
_leastSquareFit($yValues, $xValues, $const)