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 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.7.2, 2010-01-11
  26.  */
  27.  
  28.  
  29. /** PHPExcel root directory */
  30. if (!defined('PHPEXCEL_ROOT')) {
  31.     /**
  32.      * @ignore
  33.      */
  34.     define('PHPEXCEL_ROOT'dirname(__FILE__'/../../../');
  35. }
  36.  
  37. require_once(PHPEXCEL_ROOT 'PHPExcel/Shared/trend/bestFitClass.php');
  38.  
  39.  
  40. /**
  41.  * PHPExcel_Exponential_Best_Fit
  42.  *
  43.  * @category   PHPExcel
  44.  * @package    PHPExcel_Shared_Best_Fit
  45.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  46.  */
  47. {
  48.     protected $_bestFitType        = 'exponential';
  49.  
  50.  
  51.     public function getValueOfYForX($xValue{
  52.         return $this->getIntersect(pow($this->getSlope(),($xValue $this->_Xoffset));
  53.     }    //    function getValueOfYForX()
  54.  
  55.  
  56.     public function getValueOfXForY($yValue{
  57.         return log(($yValue $this->_Yoffset$this->getIntersect()) log($this->getSlope());
  58.     }    //    function getValueOfXForY()
  59.  
  60.  
  61.     public function getEquation($dp=0{
  62.         $slope $this->getSlope($dp);
  63.         $intersect $this->getIntersect($dp);
  64.  
  65.         return 'Y = '.$intersect.' * '.$slope.'^X';
  66.     }    //    function getEquation()
  67.  
  68.  
  69.     public function getSlope($dp=0{
  70.         if ($dp != 0{
  71.             return round(exp($this->_slope),$dp);
  72.         }
  73.         return exp($this->_slope);
  74.     }    //    function getSlope()
  75.  
  76.  
  77.     public function getIntersect($dp=0{
  78.         if ($dp != 0{
  79.             return round(exp($this->_intersect),$dp);
  80.         }
  81.         return exp($this->_intersect);
  82.     }    //    function getIntersect()
  83.  
  84.  
  85.     private function _exponential_regression($yValues$xValues$const{
  86.         foreach($yValues as &$value{
  87.             if ($value 0.0{
  88.                 $value log(abs($value));
  89.             elseif ($value 0.0{
  90.                 $value log($value);
  91.             }
  92.         }
  93.         unset($value);
  94.  
  95.         $this->_leastSquareFit($yValues$xValues$const);
  96.     }    //    function _exponential_regression()
  97.  
  98.  
  99.     function __construct($yValues$xValues=array()$const=True{
  100.         if (parent::__construct($yValues$xValues!== False{
  101.             $this->_exponential_regression($yValues$xValues$const);
  102.         }
  103.     }    //    function __construct()
  104.  
  105. }    //    class exponentialBestFit

Documentation generated on Mon, 11 Jan 2010 08:09:23 +0100 by phpDocumentor 1.4.1