public class LinearFit
extends java.lang.Object
y = slope * x + intercept
.Modifier and Type | Field and Description |
---|---|
protected double |
_correlationCoefficient |
protected double |
_intercept |
protected boolean |
_needsUpdate |
protected double |
_slope |
protected MutableUnivariateStatistics |
_xStats |
protected MutableUnivariateStatistics |
_xxStats |
protected MutableUnivariateStatistics |
_xyStats |
protected MutableUnivariateStatistics |
_yStats |
protected MutableUnivariateStatistics |
_yyStats |
Constructor and Description |
---|
LinearFit()
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addSample(double x,
double y)
Add a new x,y pair.
|
double |
estimateY(double x)
Estimate the dependent variable (y) given the independent variable (x).
|
double |
getCorrelationCoefficient()
Get the correlation coefficient.
|
double |
getIntercept()
Get the intercept performing a fit if needed.
|
double |
getMeanSquareOrdinateError()
Get the mean square error of the y value with respect to the fitted line.
|
double |
getSlope()
Get the slope performing a fit if needed.
|
protected void |
performFit()
Calculate the slope and intercept.
|
protected void |
performFitIfNeeded()
Perform a linear fit if the the fit needs to be updated due to newly added data.
|
java.lang.String |
toString()
Generate a string representation of the linear equation.
|
protected final MutableUnivariateStatistics _xStats
protected final MutableUnivariateStatistics _yStats
protected final MutableUnivariateStatistics _xxStats
protected final MutableUnivariateStatistics _xyStats
protected final MutableUnivariateStatistics _yyStats
protected boolean _needsUpdate
protected double _slope
protected double _intercept
protected double _correlationCoefficient
public void addSample(double x, double y)
public double getSlope()
public double getIntercept()
public double getCorrelationCoefficient()
public double estimateY(double x)
x
- the independent variablepublic double getMeanSquareOrdinateError()
protected void performFitIfNeeded()
protected void performFit()
public java.lang.String toString()
toString
in class java.lang.Object