PHPExcel_Shared_Best_Fit
[ class tree: PHPExcel_Shared_Best_Fit ] [ index: PHPExcel_Shared_Best_Fit ] [ all elements ]

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.  */
  27.  
  28.  
  29. require_once(PHPEXCEL_ROOT 'PHPExcel/Shared/trend/bestFitClass.php');
  30.  
  31.  
  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. {
  40.     protected $_bestFitType        = 'exponential';
  41.  
  42.  
  43.     public function getValueOfYForX($xValue{
  44.         return $this->getIntersect(pow($this->getSlope(),($xValue $this->_Xoffset));
  45.     }    //    function getValueOfYForX()
  46.  
  47.  
  48.     public function getValueOfXForY($yValue{
  49.         return log(($yValue $this->_Yoffset$this->getIntersect()) log($this->getSlope());
  50.     }    //    function getValueOfXForY()
  51.  
  52.  
  53.     public function getEquation($dp=0{
  54.         $slope $this->getSlope($dp);
  55.         $intersect $this->getIntersect($dp);
  56.  
  57.         return 'Y = '.$intersect.' * '.$slope.'^X';
  58.     }    //    function getEquation()
  59.  
  60.  
  61.     public function getSlope($dp=0{
  62.         if ($dp != 0{
  63.             return round(exp($this->_slope),$dp);
  64.         }
  65.         return exp($this->_slope);
  66.     }    //    function getSlope()
  67.  
  68.  
  69.     public function getIntersect($dp=0{
  70.         if ($dp != 0{
  71.             return round(exp($this->_intersect),$dp);
  72.         }
  73.         return exp($this->_intersect);
  74.     }    //    function getIntersect()
  75.  
  76.  
  77.     private function _exponential_regression($yValues$xValues$const{
  78.         foreach($yValues as &$value{
  79.             if ($value 0.0{
  80.                 $value log(abs($value));
  81.             elseif ($value 0.0{
  82.                 $value log($value);
  83.             }
  84.         }
  85.         unset($value);
  86.  
  87.         $this->_leastSquareFit($yValues$xValues$const);
  88.     }    //    function _exponential_regression()
  89.  
  90.  
  91.     function __construct($yValues$xValues=array()$const=True{
  92.         if (parent::__construct($yValues$xValues!== False{
  93.             $this->_exponential_regression($yValues$xValues$const);
  94.         }
  95.     }    //    function __construct()
  96.  
  97. }    //    class exponentialBestFit

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