public class LinearRegression
extends java.lang.Object
Constructor and Description |
---|
LinearRegression()
Private constructor, no instances allowed.
|
Modifier and Type | Method and Description |
---|---|
static double[] |
computeLinearRegression(double[] knownX,
double[] knownY,
int maxOrder)
Computes a linear regression of the given order to fit the (X, Y) data
provided using the Gauss-Markov method.
|
static double[] |
computeLinearRegression(double[] knownX,
double[] knownY,
int[] orders)
Computes a linear regression of the given order to fit the (X, Y) data
provided using the Gauss-Markov method.
|
static double[] |
computeLinearRegression(Matrix X,
double[] knownY)
Given an m by n matrix X and known y value, use the Gauss-Markov
method to compute polynomial coefficients.
|
static Matrix |
computeLinearRegression(Matrix X,
Matrix Y)
Given an m by n matrix X and an m by 1 matrix Y, use the Gauss-Markov
method to compute polynomial coefficients.
|
static double[] |
computeResiduals(double[] x,
double[] y,
double[] coefficients)
Given a set of known X and Y values, and given an array of coefficients
that describe a polynomial, compute the difference between the actual
values of Y for each X and the values of Y predicted by the polynomial.
|
static double |
computeRSquared(double[] x,
double[] y,
double[] coefficients)
Computes the coefficient of determination, R².
|
public LinearRegression()
public static double[] computeLinearRegression(double[] knownX, double[] knownY, int maxOrder) throws NonInvertibleMatrixException
knownX
- explanatory or input variablesknownY
- the response or output variables.maxOrder
- Largest exponent on x for which a coefficient will be
computed. NonInvertibleMatrixException
public static double[] computeLinearRegression(double[] knownX, double[] knownY, int[] orders) throws NonInvertibleMatrixException
knownX
- explanatory or input variablesknownY
- the response or output variables.orders
- Array of orders that are permitted to have non-zero
coefficientsNonInvertibleMatrixException
public static double[] computeLinearRegression(Matrix X, double[] knownY) throws NonInvertibleMatrixException
X
- the m by n matrix X.knownY
- the response or output variables.NonInvertibleMatrixException
public static Matrix computeLinearRegression(Matrix X, Matrix Y) throws NonInvertibleMatrixException
X
- the m by n matrix X.Y
- the m by 1 matrix Y.NonInvertibleMatrixException
public static double[] computeResiduals(double[] x, double[] y, double[] coefficients) throws java.lang.IllegalArgumentException
x
- explanatory or input variablesy
- the response or output variables.coefficients
- an array of coefficients that describe a polynomial.java.lang.IllegalArgumentException
public static double computeRSquared(double[] x, double[] y, double[] coefficients) throws java.lang.IllegalArgumentException
x
- explanatory or input variablesy
- the response or output variables.coefficients
- an array of coefficients that describe a polynomial.java.lang.IllegalArgumentException
Copyright 2004-2006 Ocean Optics, Inc. All Rights Reserved.