ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
logarithmicBestFitClass.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 = 'logarithmic';
48
49
56 public function getValueOfYForX($xValue) {
57 return $this->getIntersect() + $this->getSlope() * log($xValue - $this->_Xoffset);
58 } // function getValueOfYForX()
59
60
67 public function getValueOfXForY($yValue) {
68 return exp(($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.' * log(X)';
83 } // function getEquation()
84
85
93 private function _logarithmic_regression($yValues, $xValues, $const) {
94 foreach($xValues as &$value) {
95 if ($value < 0.0) {
96 $value = 0 - log(abs($value));
97 } elseif ($value > 0.0) {
98 $value = log($value);
99 }
100 }
101 unset($value);
102
103 $this->_leastSquareFit($yValues, $xValues, $const);
104 } // function _logarithmic_regression()
105
106
114 function __construct($yValues, $xValues=array(), $const=True) {
115 if (parent::__construct($yValues, $xValues) !== False) {
116 $this->_logarithmic_regression($yValues, $xValues, $const);
117 }
118 } // function __construct()
119
120} // class logarithmicBestFit
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)
getEquation($dp=0)
Return the Equation of the best-fit line.
getValueOfXForY($yValue)
Return the X-Value for a specified value of Y.
_logarithmic_regression($yValues, $xValues, $const)
Execute the regression and calculate the goodness of fit for a set of X and Y data values.
__construct($yValues, $xValues=array(), $const=True)
Define the regression and calculate the goodness of fit for a set of X and Y data values.
getValueOfYForX($xValue)
Return the Y-Value for a specified value of X.