LinearBestFit
extends BestFit
in package
Table of Contents
Properties
- $adjustToZero : bool
- Flag indicating whether values should be adjusted to Y=0.
- $bestFitType : string
- Algorithm type to use for best-fit (Name of this Trend class).
- $correlation : float
- $covariance : float
- $DFResiduals : float
- $error : bool
- Indicator flag for a calculation error.
- $f : float
- $goodnessOfFit : float
- $intersect : float
- $intersectSE : float
- $slope : float
- $slopeSE : float
- $SSRegression : float
- $SSResiduals : float
- $stdevOfResiduals : float
- $valueCount : int
- Number of entries in the sets of x- and y-value arrays.
- $xOffset : float
- $xValues : array<string|int, float>
- X-value dataseries of values.
- $yBestFitValues : array<string|int, float>
- Y-value series of best-fit values.
- $yOffset : float
- $yValues : array<string|int, float>
- Y-value dataseries of values.
Methods
- __construct() : mixed
- Define the regression and calculate the goodness of fit for a set of X and Y data values.
- getBestFitType() : string
- getCorrelation() : float
- getCovariance() : float
- getDFResiduals() : float
- getEquation() : string
- Return the Equation of the best-fit line.
- getError() : bool
- getF() : float
- getGoodnessOfFit() : float
- Return the goodness of fit for this regression.
- getGoodnessOfFitPercent() : float
- Return the goodness of fit for this regression.
- getIntersect() : float
- Return the Value of X where it intersects Y = 0.
- getIntersectSE() : float
- Return the standard error of the Intersect.
- getSlope() : float
- Return the Slope of the line.
- getSlopeSE() : float
- Return the standard error of the Slope.
- getSSRegression() : float
- getSSResiduals() : float
- getStdevOfResiduals() : float
- Return the standard deviation of the residuals for this regression.
- getValueOfXForY() : float
- Return the X-Value for a specified value of Y.
- getValueOfYForX() : float
- Return the Y-Value for a specified value of X.
- getXValues() : array<string|int, float>
- Return the original set of X-Values.
- getYBestFitValues() : array<string|int, float>
- calculateGoodnessOfFit() : void
- leastSquareFit() : void
- linearRegression() : void
- Execute the regression and calculate the goodness of fit for a set of X and Y data values.
- sumSquares() : float|int
Properties
$adjustToZero
Flag indicating whether values should be adjusted to Y=0.
protected
bool
$adjustToZero
= false
$bestFitType
Algorithm type to use for best-fit (Name of this Trend class).
protected
string
$bestFitType
= 'linear'
$correlation
protected
float
$correlation
= 0
$covariance
protected
float
$covariance
= 0
$DFResiduals
protected
float
$DFResiduals
= 0
$error
Indicator flag for a calculation error.
protected
bool
$error
= false
$f
protected
float
$f
= 0
$goodnessOfFit
protected
float
$goodnessOfFit
= 1
$intersect
protected
float
$intersect
= 0
$intersectSE
protected
float
$intersectSE
= 0
$slope
protected
float
$slope
= 0
$slopeSE
protected
float
$slopeSE
= 0
$SSRegression
protected
float
$SSRegression
= 0
$SSResiduals
protected
float
$SSResiduals
= 0
$stdevOfResiduals
protected
float
$stdevOfResiduals
= 0
$valueCount
Number of entries in the sets of x- and y-value arrays.
protected
int
$valueCount
$xOffset
protected
float
$xOffset
= 0
$xValues
X-value dataseries of values.
protected
array<string|int, float>
$xValues
= []
$yBestFitValues
Y-value series of best-fit values.
protected
array<string|int, float>
$yBestFitValues
= []
$yOffset
protected
float
$yOffset
= 0
$yValues
Y-value dataseries of values.
protected
array<string|int, float>
$yValues
= []
Methods
__construct()
Define the regression and calculate the goodness of fit for a set of X and Y data values.
public
__construct(array<string|int, float> $yValues[, array<string|int, float> $xValues = [] ][, bool $const = true ]) : mixed
Parameters
- $yValues : array<string|int, float>
-
The set of Y-values for this regression
- $xValues : array<string|int, float> = []
-
The set of X-values for this regression
- $const : bool = true
getBestFitType()
public
getBestFitType() : string
Return values
stringgetCorrelation()
public
getCorrelation([int $dp = 0 ]) : float
Parameters
- $dp : int = 0
-
Number of places of decimal precision to return
Return values
floatgetCovariance()
public
getCovariance([int $dp = 0 ]) : float
Parameters
- $dp : int = 0
-
Number of places of decimal precision to return
Return values
floatgetDFResiduals()
public
getDFResiduals([int $dp = 0 ]) : float
Parameters
- $dp : int = 0
-
Number of places of decimal precision to return
Return values
floatgetEquation()
Return the Equation of the best-fit line.
public
getEquation([int $dp = 0 ]) : string
Parameters
- $dp : int = 0
-
Number of places of decimal precision to display
Return values
stringgetError()
public
getError() : bool
Return values
boolgetF()
public
getF([int $dp = 0 ]) : float
Parameters
- $dp : int = 0
-
Number of places of decimal precision to return
Return values
floatgetGoodnessOfFit()
Return the goodness of fit for this regression.
public
getGoodnessOfFit([int $dp = 0 ]) : float
Parameters
- $dp : int = 0
-
Number of places of decimal precision to return
Return values
floatgetGoodnessOfFitPercent()
Return the goodness of fit for this regression.
public
getGoodnessOfFitPercent([int $dp = 0 ]) : float
Parameters
- $dp : int = 0
-
Number of places of decimal precision to return
Return values
floatgetIntersect()
Return the Value of X where it intersects Y = 0.
public
getIntersect([int $dp = 0 ]) : float
Parameters
- $dp : int = 0
-
Number of places of decimal precision to display
Return values
floatgetIntersectSE()
Return the standard error of the Intersect.
public
getIntersectSE([int $dp = 0 ]) : float
Parameters
- $dp : int = 0
-
Number of places of decimal precision to display
Return values
floatgetSlope()
Return the Slope of the line.
public
getSlope([int $dp = 0 ]) : float
Parameters
- $dp : int = 0
-
Number of places of decimal precision to display
Return values
floatgetSlopeSE()
Return the standard error of the Slope.
public
getSlopeSE([int $dp = 0 ]) : float
Parameters
- $dp : int = 0
-
Number of places of decimal precision to display
Return values
floatgetSSRegression()
public
getSSRegression([int $dp = 0 ]) : float
Parameters
- $dp : int = 0
-
Number of places of decimal precision to return
Return values
floatgetSSResiduals()
public
getSSResiduals([int $dp = 0 ]) : float
Parameters
- $dp : int = 0
-
Number of places of decimal precision to return
Return values
floatgetStdevOfResiduals()
Return the standard deviation of the residuals for this regression.
public
getStdevOfResiduals([int $dp = 0 ]) : float
Parameters
- $dp : int = 0
-
Number of places of decimal precision to return
Return values
floatgetValueOfXForY()
Return the X-Value for a specified value of Y.
public
getValueOfXForY(float $yValue) : float
Parameters
- $yValue : float
-
Y-Value
Return values
float —X-Value
getValueOfYForX()
Return the Y-Value for a specified value of X.
public
getValueOfYForX(float $xValue) : float
Parameters
- $xValue : float
-
X-Value
Return values
float —Y-Value
getXValues()
Return the original set of X-Values.
public
getXValues() : array<string|int, float>
Return values
array<string|int, float> —X-Values
getYBestFitValues()
public
getYBestFitValues() : array<string|int, float>
Return values
array<string|int, float>calculateGoodnessOfFit()
protected
calculateGoodnessOfFit(float $sumX, float $sumY, float $sumX2, float $sumY2, float $sumXY, float $meanX, float $meanY, bool|int $const) : void
Parameters
- $sumX : float
- $sumY : float
- $sumX2 : float
- $sumY2 : float
- $sumXY : float
- $meanX : float
- $meanY : float
- $const : bool|int
leastSquareFit()
protected
leastSquareFit(array<string|int, float> $yValues, array<string|int, float> $xValues, bool $const) : void
Parameters
- $yValues : array<string|int, float>
- $xValues : array<string|int, float>
- $const : bool
linearRegression()
Execute the regression and calculate the goodness of fit for a set of X and Y data values.
private
linearRegression(array<string|int, float> $yValues, array<string|int, float> $xValues, bool $const) : void
Parameters
- $yValues : array<string|int, float>
-
The set of Y-values for this regression
- $xValues : array<string|int, float>
-
The set of X-values for this regression
- $const : bool
sumSquares()
private
sumSquares(array<string|int, mixed> $values) : float|int
Parameters
- $values : array<string|int, mixed>