File Source for exponentialBestFitClass.php

PHPExcel_Shared_Best_Fit

# Source for file exponentialBestFitClass.php

Documentation is available at exponentialBestFitClass.php

1. <?php
2. /**
3. * PHPExcel
4. *
5. * Copyright (c) 2006 - 2011 PHPExcel
6. *
7. * This library is free software; you can redistribute it and/or
8. * modify it under the terms of the GNU Lesser General Public
9. * License as published by the Free Software Foundation; either
10. * version 2.1 of the License, or (at your option) any later version.
11. *
12. * This library is distributed in the hope that it will be useful,
13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15. * Lesser General Public License for more details.
16. *
17. * You should have received a copy of the GNU Lesser General Public
18. * License along with this library; if not, write to the Free Software
19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20. *
21. * @category PHPExcel
22. * @package PHPExcel_Shared_Best_Fit
23. * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25. * @version 1.7.6, 2011-02-27
26. */
29. require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
32. /**
33. * PHPExcel_Exponential_Best_Fit
34. *
35. * @category PHPExcel
36. * @package PHPExcel_Shared_Best_Fit
37. * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
38. */
39. class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
40. {
41. protected $_bestFitType = 'exponential';
44. public function getValueOfYForX($xValue) {
45. return $this-> getIntersect() * pow($this-> getSlope(),($xValue - $this->_Xoffset));
46. } // function getValueOfYForX()
49. public function getValueOfXForY($yValue) {
50. return log(($yValue + $this->_Yoffset) / $this-> getIntersect()) / log($this-> getSlope());
51. } // function getValueOfXForY()
54. public function getEquation($dp=0) {
55. $slope = $this-> getSlope($dp);
56. $intersect = $this-> getIntersect($dp);
58. return 'Y = '.$intersect.' * '.$slope.'^X';
59. } // function getEquation()
62. public function getSlope($dp=0) {
63. if ($dp != 0) {
64. return round( exp($this->_slope),$dp);
65. }
66. return exp($this->_slope);
67. } // function getSlope()
70. public function getIntersect($dp=0) {
71. if ($dp != 0) {
72. return round( exp($this->_intersect),$dp);
73. }
74. return exp($this->_intersect);
75. } // function getIntersect()
78. private function _exponential_regression($yValues, $xValues, $const) {
79. foreach($yValues as &$value) {
80. if ($value < 0.0) {
81. $value = 0 - log( abs($value));
82. } elseif ($value > 0.0) {
83. $value = log($value);
84. }
85. }
86. unset($value);
88. $this->_leastSquareFit($yValues, $xValues, $const);
89. } // function _exponential_regression()
92. function __construct($yValues, $xValues=array(), $const=True) {
93. if (parent::__construct($yValues, $xValues) !== False) {
94. $this->_exponential_regression($yValues, $xValues, $const);
95. }
96. } // function __construct()
98. } // class exponentialBestFit

Documentation generated on Sun, 27 Feb 2011 16:31:30 -0800 by phpDocumentor 1.4.3