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

Source for file logarithmicBestFitClass.php

Documentation is available at logarithmicBestFitClass.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_Logarithmic_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        = 'logarithmic';
  41.  
  42.  
  43.     public function getValueOfYForX($xValue{
  44.         return $this->getIntersect($this->getSlope(log($xValue $this->_Xoffset);
  45.     }    //    function getValueOfYForX()
  46.  
  47.  
  48.     public function getValueOfXForY($yValue{
  49.         return exp(($yValue $this->getIntersect()) $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.' * log(X)';
  58.     }    //    function getEquation()
  59.  
  60.  
  61.     private function _logarithmic_regression($yValues$xValues$const{
  62.         foreach($xValues as &$value{
  63.             if ($value 0.0{
  64.                 $value log(abs($value));
  65.             elseif ($value 0.0{
  66.                 $value log($value);
  67.             }
  68.         }
  69.         unset($value);
  70.  
  71.         $this->_leastSquareFit($yValues$xValues$const);
  72.     }    //    function _logarithmic_regression()
  73.  
  74.  
  75.     function __construct($yValues$xValues=array()$const=True{
  76.         if (parent::__construct($yValues$xValues!== False{
  77.             $this->_logarithmic_regression($yValues$xValues$const);
  78.         }
  79.     }    //    function __construct()
  80.  
  81. }    //    class logarithmicBestFit

Documentation generated on Sun, 27 Feb 2011 16:32:29 -0800 by phpDocumentor 1.4.3