ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
exponentialBestFitClass.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 = 'exponential';
48
49
56 public function getValueOfYForX($xValue) {
57 return $this->getIntersect() * pow($this->getSlope(),($xValue - $this->_Xoffset));
58 } // function getValueOfYForX()
59
60
67 public function getValueOfXForY($yValue) {
68 return log(($yValue + $this->_Yoffset) / $this->getIntersect()) / log($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
92 public function getSlope($dp=0) {
93 if ($dp != 0) {
94 return round(exp($this->_slope),$dp);
95 }
96 return exp($this->_slope);
97 } // function getSlope()
98
99
106 public function getIntersect($dp=0) {
107 if ($dp != 0) {
108 return round(exp($this->_intersect),$dp);
109 }
110 return exp($this->_intersect);
111 } // function getIntersect()
112
113
121 private function _exponential_regression($yValues, $xValues, $const) {
122 foreach($yValues as &$value) {
123 if ($value < 0.0) {
124 $value = 0 - log(abs($value));
125 } elseif ($value > 0.0) {
126 $value = log($value);
127 }
128 }
129 unset($value);
130
131 $this->_leastSquareFit($yValues, $xValues, $const);
132 } // function _exponential_regression()
133
134
142 function __construct($yValues, $xValues=array(), $const=True) {
143 if (parent::__construct($yValues, $xValues) !== False) {
144 $this->_exponential_regression($yValues, $xValues, $const);
145 }
146 } // function __construct()
147
148} // class exponentialBestFit
An exception for terminatinating execution or to throw for unit testing.
_leastSquareFit($yValues, $xValues, $const)
getSlope($dp=0)
Return the Slope of the 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.
getIntersect($dp=0)
Return the Value of X where it intersects Y = 0.
_exponential_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.
getValueOfYForX($xValue)
Return the Y-Value for a specified value of X.
getValueOfXForY($yValue)
Return the X-Value for a specified value of Y.