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

Source for file powerBestFitClass.php

Documentation is available at powerBestFitClass.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_Power_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        = 'power';
  41.  
  42.  
  43.     public function getValueOfYForX($xValue{
  44.         return $this->getIntersect(pow(($xValue $this->_Xoffset),$this->getSlope());
  45.     }    //    function getValueOfYForX()
  46.  
  47.  
  48.     public function getValueOfXForY($yValue{
  49.         return pow((($yValue $this->_Yoffset$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.' * X^'.$slope;
  58.     }    //    function getEquation()
  59.  
  60.  
  61.     public function getIntersect($dp=0{
  62.         if ($dp != 0{
  63.             return round(exp($this->_intersect),$dp);
  64.         }
  65.         return exp($this->_intersect);
  66.     }    //    function getIntersect()
  67.  
  68.  
  69.     private function _power_regression($yValues$xValues$const{
  70.         foreach($xValues as &$value{
  71.             if ($value 0.0{
  72.                 $value log(abs($value));
  73.             elseif ($value 0.0{
  74.                 $value log($value);
  75.             }
  76.         }
  77.         unset($value);
  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 _power_regression()
  89.  
  90.  
  91.     function __construct($yValues$xValues=array()$const=True{
  92.         if (parent::__construct($yValues$xValues!== False{
  93.             $this->_power_regression($yValues$xValues$const);
  94.         }
  95.     }    //    function __construct()
  96.  
  97. }    //    class powerBestFit

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