public class PolynomialRegression extends java.lang.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(java.lang.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.
|
java.lang.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 fitjava.lang.IllegalArgumentException - 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 java.lang.String toString()
toString in class java.lang.Objectpublic static void main(java.lang.String[] args)