public class PolynomialRegression extends Object
This implementation performs a QR-decomposition of the underlying Vandermonde matrix, so it is not the fastest or most numerically stable way to perform the polynomial regression.
| Constructor and Description |
|---|
PolynomialRegression(double[] x,
double[] y,
int degree)
Performs a polynomial reggression on the data points (y[i], x[i]).
|
| Modifier and Type | Method and Description |
|---|---|
double |
beta(int j)
Returns the jth regression coefficient
|
int |
degree()
Returns the degree of the polynomial to fit
|
static void |
main(String[] args) |
double |
predict(double x)
Returns the expected response y given the value of the predictor
variable x.
|
double |
R2()
Returns the coefficient of determination R2.
|
String |
toString()
Returns a string representation of the polynomial regression model.
|
public PolynomialRegression(double[] x,
double[] y,
int degree)
x - the values of the predictor variabley - the corresponding values of the response variabledegree - the degree of the polynomial to fitIllegalArgumentException - if the lengths of the two arrays are not equalpublic double beta(int j)
public int degree()
public double R2()
public double predict(double x)
x - the value of the predictor variablepublic String toString()
public static void main(String[] args)
Copyright © 2014. All Rights Reserved.