Package org.jfree.data.statistics
Class Regression
- java.lang.Object
-
- org.jfree.data.statistics.Regression
-
public abstract class Regression extends java.lang.Object
A utility class for fitting regression curves to data.
-
-
Constructor Summary
Constructors Constructor Description Regression()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static double[][]
calculateSubMatrix(double[][] matrix)
Returns a matrix with the following features: (1) the number of rows and columns is 1 less than that of the original matrix; (2)the matrix is triangular, i.e.static double[]
getOLSRegression(double[][] data)
Returns the parameters 'a' and 'b' for an equation y = a + bx, fitted to the data using ordinary least squares regression.static double[]
getOLSRegression(XYDataset data, int series)
Returns the parameters 'a' and 'b' for an equation y = a + bx, fitted to the data using ordinary least squares regression.static double[]
getPolynomialRegression(XYDataset dataset, int series, int order)
Returns the parameters 'a0', 'a1', 'a2', ..., 'an' for a polynomial function of order n, y = a0 + a1 * x + a2 * x^2 + ...static double[]
getPowerRegression(double[][] data)
Returns the parameters 'a' and 'b' for an equation y = ax^b, fitted to the data using a power regression equation.static double[]
getPowerRegression(XYDataset data, int series)
Returns the parameters 'a' and 'b' for an equation y = ax^b, fitted to the data using a power regression equation.
-
-
-
Method Detail
-
getOLSRegression
public static double[] getOLSRegression(double[][] data)
Returns the parameters 'a' and 'b' for an equation y = a + bx, fitted to the data using ordinary least squares regression. The result is returned as a double[], where result[0] --> a, and result[1] --> b.- Parameters:
data
- the data.- Returns:
- The parameters.
-
getOLSRegression
public static double[] getOLSRegression(XYDataset data, int series)
Returns the parameters 'a' and 'b' for an equation y = a + bx, fitted to the data using ordinary least squares regression. The result is returned as a double[], where result[0] --> a, and result[1] --> b.- Parameters:
data
- the data.series
- the series (zero-based index).- Returns:
- The parameters.
-
getPowerRegression
public static double[] getPowerRegression(double[][] data)
Returns the parameters 'a' and 'b' for an equation y = ax^b, fitted to the data using a power regression equation. The result is returned as an array, where double[0] --> a, and double[1] --> b.- Parameters:
data
- the data.- Returns:
- The parameters.
-
getPowerRegression
public static double[] getPowerRegression(XYDataset data, int series)
Returns the parameters 'a' and 'b' for an equation y = ax^b, fitted to the data using a power regression equation. The result is returned as an array, where double[0] --> a, and double[1] --> b.- Parameters:
data
- the data.series
- the series to fit the regression line against.- Returns:
- The parameters.
-
getPolynomialRegression
public static double[] getPolynomialRegression(XYDataset dataset, int series, int order)
Returns the parameters 'a0', 'a1', 'a2', ..., 'an' for a polynomial function of order n, y = a0 + a1 * x + a2 * x^2 + ... + an * x^n, fitted to the data using a polynomial regression equation. The result is returned as an array with a length of n + 2, where double[0] --> a0, double[1] --> a1, .., double[n] --> an. and double[n + 1] is the correlation coefficient R2 Reference: J. D. Faires, R. L. Burden, Numerische Methoden (german edition), pp. 243ff and 327ff.- Parameters:
dataset
- the dataset (null
not permitted).series
- the series to fit the regression line against (the series must have at least order + 1 non-NaN items).order
- the order of the function (> 0).- Returns:
- The parameters.
-
calculateSubMatrix
private static double[][] calculateSubMatrix(double[][] matrix)
Returns a matrix with the following features: (1) the number of rows and columns is 1 less than that of the original matrix; (2)the matrix is triangular, i.e. all elements a (row, column) with column > row are zero. This method is used for calculating a polynomial regression.- Parameters:
matrix
- the start matrix.- Returns:
- The new matrix.
-
-