Package pamMaths
Class Regressions
java.lang.Object
pamMaths.Regressions
Class for performing various regressions. Relies heavily on the Matrixes and other utilities in the
JAMA package. Developers must download JAMA and install the jar file into their JAVA path.
see http://math.nist.gov/javanumerics/jama/
- Author:
- Douglas Gillespie
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
getMean
(double[] y) Get the mean of a set of valuesstatic double[]
linFit
(double[] x, double[] y) Fit a linear regression line to a set of pointsstatic double[]
meanFit
(double[] y) Return the mean of a set of points as a one element array for compatibility with other, higher order fits.static double[]
polyFit
(double[] x, double[] y, int order) static double[]
squareFit
(double[] x, double[] y) Fit a second order polynomial to a set of pointsstatic double
value
(double[] fitParams, double x) Use the parameters of the fit to calculate a value using the fitParams polynomial.
-
Constructor Details
-
Regressions
public Regressions()
-
-
Method Details
-
polyFit
public static double[] polyFit(double[] x, double[] y, int order) -
meanFit
public static double[] meanFit(double[] y) Return the mean of a set of points as a one element array for compatibility with other, higher order fits.- Parameters:
y
- array ofvalues- Returns:
- the mean value as a one element array
-
getMean
public static double getMean(double[] y) Get the mean of a set of values- Parameters:
y
- array ofvalues- Returns:
- the mean value
-
linFit
public static double[] linFit(double[] x, double[] y) Fit a linear regression line to a set of points- Parameters:
x
- array of x coordinatesy
- array of y coordinates- Returns:
- the two coefficients for the fit
-
squareFit
public static double[] squareFit(double[] x, double[] y) Fit a second order polynomial to a set of points- Parameters:
x
- array of x coordinatesy
- array of y coordinates- Returns:
- the three coefficients for the fit or null if a fit is not possible.
-
value
public static double value(double[] fitParams, double x) Use the parameters of the fit to calculate a value using the fitParams polynomial.- Parameters:
fitParams
- parameters of the fitx
- x value- Returns:
- y value = fitParams[0] + fitParams[1]*x + fitParams[2]*x^2, etc...
-