Class PolyFit

java.lang.Object
dataAnalysis.PolyFit

public class PolyFit extends Object
This class performs polynomial fitting on given data: there are two alghorithms.
Author:
Federico Granata
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 variable
      y - 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 data
      x - values of the independent variable
      y - values of the dependent variable (data)
      sd - the standard deviation of dependent point
      order - the order of the polynomial
      Returns:
      array (of order+1 double) of the coefficients of the polynomial