PHPExcel_Shared_Trend

# Class: PHPExcel_Best_Fit

Source Location: /PHPExcel/Shared/trend/bestFitClass.php

### Class Overview

PHPExcel_Best_Fit

#### Author(s):

#### Copyright:

- Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)

### Variables

- $_adjustToZero
- $_bestFitType
- $_correlation
- $_covariance
- $_DFResiduals
- $_error
- $_F
- $_goodnessOfFit
- $_intersect
- $_intersectSE
- $_slope
- $_slopeSE
- $_SSRegression
- $_SSResiduals
- $_stdevOfResiduals
- $_valueCount
- $_Xoffset
- $_xValues
- $_yBestFitValues
- $_Yoffset
- $_yValues

### Methods

- __construct
- getBestFitType
- getCorrelation
- getCovariance
- getDFResiduals
- getEquation
- getError
- getF
- getGoodnessOfFit
- getGoodnessOfFitPercent
- getIntersect
- getIntersectSE
- getSlope
- getSlopeSE
- getSSRegression
- getSSResiduals
- getStdevOfResiduals
- getValueOfXForY
- getValueOfYForX
- getXValues
- getYBestFitValues
- _calculateGoodnessOfFit
- _leastSquareFit

### Child classes:

PHPExcel_Exponential_Best_Fit
  PHPExcel_Exponential_Best_Fit

PHPExcel_Linear_Best_Fit
  PHPExcel_Linear_Best_Fit

PHPExcel_Logarithmic_Best_Fit
  PHPExcel_Logarithmic_Best_Fit

PHPExcel_Polynomial_Best_Fit
  PHPExcel_Polynomial_Best_Fit

PHPExcel_Power_Best_Fit
  PHPExcel_Power_Best_Fit

### Class Details

[line 36]
PHPExcel_Best_Fit

#### Tags:

copyright: | Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)

[ Top ]

### Class Variables

#### $_adjustToZero = False

[line 78]

Flag indicating whether values should be adjusted to Y=0

#### Tags:

access: | protected

Type: | boolean

[ Top ]

#### $_bestFitType = 'undetermined'

[line 50]

Algorithm type to use for best-fit

#### Tags:

access: | protected

Type: | string

[ Top ]

#### $_correlation = 0

[line 93]

#### Tags:

access: | protected

Type: | mixed

[ Top ]

#### $_covariance = 0

[line 91]

#### Tags:

access: | protected

Type: | mixed

[ Top ]

#### $_DFResiduals = 0

[line 99]

#### Tags:

access: | protected

Type: | mixed

[ Top ]

#### $_error = False

[line 43]

Indicator flag for a calculation error

#### Tags:

access: | protected

Type: | boolean

[ Top ]

#### $_F = 0

[line 101]

#### Tags:

access: | protected

Type: | mixed

[ Top ]

#### $_goodnessOfFit = 1

[line 87]

#### Tags:

access: | protected

Type: | mixed

[ Top ]

#### $_intersect = 0

[line 107]

#### Tags:

access: | protected

Type: | mixed

[ Top ]

#### $_intersectSE = 0

[line 109]

#### Tags:

access: | protected

Type: | mixed

[ Top ]

#### $_slope = 0

[line 103]

#### Tags:

access: | protected

Type: | mixed

[ Top ]

#### $_slopeSE = 0

[line 105]

#### Tags:

access: | protected

Type: | mixed

[ Top ]

#### $_SSRegression = 0

[line 95]

#### Tags:

access: | protected

Type: | mixed

[ Top ]

#### $_SSResiduals = 0

[line 97]

#### Tags:

access: | protected

Type: | mixed

[ Top ]

#### $_stdevOfResiduals = 0

[line 89]

#### Tags:

access: | protected

Type: | mixed

[ Top ]

#### $_valueCount = 0

[line 57]

Number of entries in the sets of x- and y-value arrays

#### Tags:

access: | protected

Type: | int

[ Top ]

#### $_Xoffset = 0

[line 111]

#### Tags:

access: | protected

Type: | mixed

[ Top ]

#### $_xValues = array()

[line 64]

X-value dataseries of values

#### Tags:

access: | protected

Type: | float[]

[ Top ]

#### $_yBestFitValues = array()

[line 85]

Y-value series of best-fit values

#### Tags:

access: | protected

Type: | float[]

[ Top ]

#### $_Yoffset = 0

[line 113]

#### Tags:

access: | protected

Type: | mixed

[ Top ]

#### $_yValues = array()

[line 71]

Y-value dataseries of values

#### Tags:

access: | protected

Type: | float[]

[ Top ]

### Class Methods

### constructor __construct [line 412]

`PHPExcel_Best_Fit __construct( float[] $yValues, [float[] $xValues = array()], [boolean $const = True])`

Define the regression

Overridden in child classes as:

PHPExcel_Exponential_Best_Fit::__construct()
  Define the regression and calculate the goodness of fit for a set of X and Y data values

PHPExcel_Linear_Best_Fit::__construct()
  Define the regression and calculate the goodness of fit for a set of X and Y data values

PHPExcel_Logarithmic_Best_Fit::__construct()
  Define the regression and calculate the goodness of fit for a set of X and Y data values

PHPExcel_Polynomial_Best_Fit::__construct()
  Define the regression and calculate the goodness of fit for a set of X and Y data values

PHPExcel_Power_Best_Fit::__construct()
  Define the regression and calculate the goodness of fit for a set of X and Y data values

#### Parameters:

float[] | $yValues | The set of Y-values for this regression
float[] | $xValues | The set of X-values for this regression
boolean | $const |

[ Top ]

### method getBestFitType [line 121]

`void getBestFitType( )`

#### Tags:

access: | public

[ Top ]

### method getCorrelation [line 301]

`void getCorrelation( [ $dp = 0])`

#### Tags:

access: | public

#### Parameters:

| $dp |

[ Top ]

### method getCovariance [line 293]

`void getCovariance( [ $dp = 0])`

#### Tags:

access: | public

#### Parameters:

| $dp |

[ Top ]

### method getDFResiduals [line 277]

`void getDFResiduals( [ $dp = 0])`

#### Tags:

access: | public

#### Parameters:

| $dp |

[ Top ]

### method getEquation [line 164]

`string getEquation( [int $dp = 0])`

Return the Equation of the best-fit line

#### Tags:

access: | public

Overridden in child classes as:

PHPExcel_Exponential_Best_Fit::getEquation()
  Return the Equation of the best-fit line

PHPExcel_Linear_Best_Fit::getEquation()
  Return the Equation of the best-fit line

PHPExcel_Logarithmic_Best_Fit::getEquation()
  Return the Equation of the best-fit line

PHPExcel_Polynomial_Best_Fit::getEquation()
  Return the Equation of the best-fit line

PHPExcel_Power_Best_Fit::getEquation()
  Return the Equation of the best-fit line

#### Parameters:

int | $dp | Number of places of decimal precision to display

[ Top ]

### method getError [line 116]

`void getError( )`

#### Tags:

access: | public

[ Top ]

### method getF [line 285]

`void getF( [ $dp = 0])`

#### Tags:

access: | public

#### Parameters:

| $dp |

[ Top ]

### method getGoodnessOfFit [line 231]

`float getGoodnessOfFit( [int $dp = 0])`

Return the goodness of fit for this regression

#### Tags:

access: | public

#### Parameters:

int | $dp | Number of places of decimal precision to return

[ Top ]

### method getGoodnessOfFitPercent [line 239]

`void getGoodnessOfFitPercent( [ $dp = 0])`

#### Tags:

access: | public

#### Parameters:

| $dp |

[ Top ]

### method getIntersect [line 203]

`string getIntersect( [int $dp = 0])`

Return the Value of X where it intersects Y = 0

#### Tags:

access: | public

Overridden in child classes as:

PHPExcel_Exponential_Best_Fit::getIntersect()
  Return the Value of X where it intersects Y = 0

PHPExcel_Power_Best_Fit::getIntersect()
  Return the Value of X where it intersects Y = 0

#### Parameters:

int | $dp | Number of places of decimal precision to display

[ Top ]

### method getIntersectSE [line 217]

`string getIntersectSE( [int $dp = 0])`

Return the standard error of the Intersect

#### Tags:

access: | public

#### Parameters:

int | $dp | Number of places of decimal precision to display

[ Top ]

### method getSlope [line 175]

`string getSlope( [int $dp = 0])`

Return the Slope of the line

#### Tags:

access: | public

Overridden in child classes as:

PHPExcel_Exponential_Best_Fit::getSlope()
  Return the Slope of the line

PHPExcel_Polynomial_Best_Fit::getSlope()
  Return the Slope of the line

#### Parameters:

int | $dp | Number of places of decimal precision to display

[ Top ]

### method getSlopeSE [line 189]

`string getSlopeSE( [int $dp = 0])`

Return the standard error of the Slope

#### Tags:

access: | public

#### Parameters:

int | $dp | Number of places of decimal precision to display

[ Top ]

### method getSSRegression [line 261]

`void getSSRegression( [ $dp = 0])`

#### Tags:

access: | public

#### Parameters:

| $dp |

[ Top ]

### method getSSResiduals [line 269]

`void getSSResiduals( [ $dp = 0])`

#### Tags:

access: | public

#### Parameters:

| $dp |

[ Top ]

### method getStdevOfResiduals [line 253]

`float getStdevOfResiduals( [int $dp = 0])`

Return the standard deviation of the residuals for this regression

#### Tags:

access: | public

#### Parameters:

int | $dp | Number of places of decimal precision to return

[ Top ]

### method getValueOfXForY [line 143]

`float getValueOfXForY( float $yValue)`

Return the X-Value for a specified value of Y

#### Tags:

return: | X-Value
access: | public

Overridden in child classes as:

PHPExcel_Exponential_Best_Fit::getValueOfXForY()
  Return the X-Value for a specified value of Y

PHPExcel_Linear_Best_Fit::getValueOfXForY()
  Return the X-Value for a specified value of Y

PHPExcel_Logarithmic_Best_Fit::getValueOfXForY()
  Return the X-Value for a specified value of Y

PHPExcel_Polynomial_Best_Fit::getValueOfXForY()
  Return the X-Value for a specified value of Y

PHPExcel_Power_Best_Fit::getValueOfXForY()
  Return the X-Value for a specified value of Y

#### Parameters:

float | $yValue | Y-Value

[ Top ]

### method getValueOfYForX [line 132]

`float getValueOfYForX( float $xValue)`

Return the Y-Value for a specified value of X

#### Tags:

return: | Y-Value
access: | public

Overridden in child classes as:

PHPExcel_Exponential_Best_Fit::getValueOfYForX()
  Return the Y-Value for a specified value of X

PHPExcel_Linear_Best_Fit::getValueOfYForX()
  Return the Y-Value for a specified value of X

PHPExcel_Logarithmic_Best_Fit::getValueOfYForX()
  Return the Y-Value for a specified value of X

PHPExcel_Polynomial_Best_Fit::getValueOfYForX()
  Return the Y-Value for a specified value of X

PHPExcel_Power_Best_Fit::getValueOfYForX()
  Return the Y-Value for a specified value of X

#### Parameters:

float | $xValue | X-Value

[ Top ]

### method getXValues [line 153]

`float[] getXValues( )`

Return the original set of X-Values

#### Tags:

return: | X-Values
access: | public

[ Top ]

### method getYBestFitValues [line 309]

`void getYBestFitValues( )`

#### Tags:

access: | public

[ Top ]

### method _calculateGoodnessOfFit [line 314]

`void _calculateGoodnessOfFit( $sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const)`

#### Tags:

access: | protected

#### Parameters:

| $sumX |
| $sumY |
| $sumX2 |
| $sumY2 |
| $sumXY |
| $meanX |
| $meanY |
| $const |

[ Top ]

### method _leastSquareFit [line 368]

`void _leastSquareFit( $yValues, $xValues, $const)`

#### Tags:

access: | protected

#### Parameters:

| $yValues |
| $xValues |
| $const |

[ Top ]

Documentation generated on Fri, 12 Oct 2012 00:15:15 +0200 by phpDocumentor 1.4.4