Class PolyFit
java.lang.Object
dataAnalysis.PolyFit
This class performs polynomial fitting on given data: there are two
alghorithms.
- Author:
- Federico Granata
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic double[]fit(int ndata, double[] x, double[] y, int order) fit: returns the coefficients of the polynomial which best approximates f (in the mean square error sense) for the given data.static double[]fitSVD(int ndata, double[] x, double[] y, double[] sd, int order) fitSVD: returns the coefficients of the polynomial which best approximates f (in the mean square error sense) for the given data.
-
Constructor Details
-
PolyFit
public PolyFit()
-
-
Method Details
-
fit
public static double[] fit(int ndata, double[] x, double[] y, int order) fit: returns the coefficients of the polynomial which best approximates f (in the mean square error sense) for the given data. y = f(x). y' = a0 + a1 x + ..... + an x^(order)- Parameters:
ndata- number of data;x- values of the independent variabley- values of the dependent variable (data)order- the order of the polynomial- Returns:
- array (of order+1 double) of the coefficients of the polynomial
-
fitSVD
public static double[] fitSVD(int ndata, double[] x, double[] y, double[] sd, int order) fitSVD: returns the coefficients of the polynomial which best approximates f (in the mean square error sense) for the given data. y = f(x). y' = a0 + a1 x + ..... + an x^(order) it uses the Singular Value Decomposition tecnique, very stable. For a complete description see "Numerical recipes in C"- Parameters:
ndata- number of datax- values of the independent variabley- values of the dependent variable (data)sd- the standard deviation of dependent pointorder- the order of the polynomial- Returns:
- array (of order+1 double) of the coefficients of the polynomial
-