public class LeastSquaresLinearModel extends Object implements EstimatableModel<Integer,Integer>
Constructor and Description |
---|
LeastSquaresLinearModel()
Construct model
|
LeastSquaresLinearModel(int nEstimates)
Construct model
|
Modifier and Type | Method and Description |
---|---|
LeastSquaresLinearModel |
clone()
Clone the model
|
boolean |
estimate(List<? extends IndependentPair<Integer,Integer>> data)
Using standard vertical linear regression as outlined here:
http://mathworld.wolfram.com/LeastSquaresFitting.html
calculate the m and c of a line of best fit given the data.
|
double |
getC()
Get the offset (c in y=mx+c)
|
double |
getM()
Get the gradient (m in y=mx+c)
|
int |
numItemsToEstimate() |
Integer |
predict(Integer data)
Uses the model to predict dependent data from an independent value.
|
String |
toString() |
public LeastSquaresLinearModel()
public LeastSquaresLinearModel(int nEstimates)
nEstimates
- minimum number of samples required for estimating model when
fittingpublic boolean estimate(List<? extends IndependentPair<Integer,Integer>> data)
estimate
in interface EstimatableModel<Integer,Integer>
data
- Observed dataEstimatableModel.numItemsToEstimate()
public Integer predict(Integer data)
Model
public int numItemsToEstimate()
numItemsToEstimate
in interface EstimatableModel<Integer,Integer>
public LeastSquaresLinearModel clone()
EstimatableModel
public double getM()
public double getC()