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 - 2009 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.7.0, 2009-08-10
  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_Power_Best_Fit
  42.  *
  43.  * @category   PHPExcel
  44.  * @package    PHPExcel_Shared_Best_Fit
  45.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  46.  */
  47. {
  48.     protected $_bestFitType        = 'power';
  49.  
  50.  
  51.     public function getValueOfYForX($xValue{
  52.         return $this->getIntersect(pow(($xValue $this->_Xoffset),$this->getSlope());
  53.     }    //    function getValueOfYForX()
  54.  
  55.  
  56.     public function getValueOfXForY($yValue{
  57.         return pow((($yValue $this->_Yoffset$this->getIntersect()),($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.' * X^'.$slope;
  66.     }    //    function getEquation()
  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 _power_regression($yValues$xValues$const{
  78.         $mArray $xValues;
  79.         sort($mArray,SORT_NUMERIC);
  80.         $xValues array_map('log',$xValues);
  81.         $yValues array_map('log',$yValues);
  82.  
  83.         $this->_leastSquareFit($yValues$xValues$const);
  84.     }    //    function _power_regression()
  85.  
  86.  
  87.     function __construct($yValues$xValues=array()$const=True{
  88.         if (parent::__construct($yValues$xValues!== False{
  89.             $this->_power_regression($yValues$xValues$const);
  90.         }
  91.     }    //    function __construct()
  92.  
  93. }    //    class powerBestFit

Documentation generated on Mon, 10 Aug 2009 08:07:24 +0200 by phpDocumentor 1.4.1