Class Polynomial

java.lang.Object
xal.extension.fit.lsm.Polynomial

public class Polynomial extends Object
This class is for data fitting with polynomial equation.
Author:
shishlo
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of Polynomial
    Polynomial(int n)
    Creates a new instance of Polynomial
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addData(double x, double y)
    Adds a data point to the internal data
    void
    addData(double x, double y, double yErr)
    Adds a data point to the internal data
    void
    Removes all internal data
    Return the characteristic equation as a String
    boolean
    fit()
    It performs one step of the data fit
    boolean
    It performs one step of the data fit by using centered data.
    boolean
    fitParameter(int index)
    Returns the boolean variable about including the coefficient into the fitting
    void
    fitParameter(int index, boolean fitting)
    Includes or excludes the parameter into fitting
    double[]
    Returns the array with the coefficients of the Polynomial
    double[]
    Returns the array with the errors of the coefficients of the Polynomial
    int
    Returns the order of the Polynomial object
    double
    getParameter(int index)
    Returns the parameter value
    double
    getParameterError(int index)
    Returns the parameter value error
    double
    getValue(double x)
    Returns the value of Polynomial function
    double
    getValue(double x, double[] a)
    Returns the value of Polynomial function
    static void
    main(String[] args)
    MAIN for debugging
    void
    setData(double[] xArr, double[] yArr)
    Sets the data attribute of the Polynomial object
    void
    setData(double[] xArr, double[] yArr, double[] yErrArr)
    Sets the data attribute of the Polynomial object
    void
    setOrder(int n)
    Sets the order of the Polynomial object
    void
    setParameter(int index, double val)
    Sets the parameter value

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Polynomial

      public Polynomial()
      Creates a new instance of Polynomial
    • Polynomial

      public Polynomial(int n)
      Creates a new instance of Polynomial
      Parameters:
      n - The order of the Polynomial object
  • Method Details

    • getParameter

      public double getParameter(int index)
      Returns the parameter value
      Parameters:
      index - The coefficient for power "index" of the polynomial
      Returns:
      The parameter value
    • getParameterError

      public double getParameterError(int index)
      Returns the parameter value error
      Parameters:
      index - The coefficient index for power equals to "index" in the polynomial
      Returns:
      The parameter value error
    • fitParameter

      public void fitParameter(int index, boolean fitting)
      Includes or excludes the parameter into fitting
      Parameters:
      index - The coefficient index for power equals to "index" in the polynomial
      fitting - The boolean variable about including the coefficient into the fitting
    • fitParameter

      public boolean fitParameter(int index)
      Returns the boolean variable about including the coefficient into the fitting
      Parameters:
      index - The coefficient index for power equals to "index" in the polynomial
      Returns:
      fitting The boolean variable about including the coefficient into the fitting
    • setParameter

      public void setParameter(int index, double val)
      Sets the parameter value
      Parameters:
      val - The new parameter value
      index - he coefficient index for power equals to "index" in the polynomial
    • setData

      public void setData(double[] xArr, double[] yArr, double[] yErrArr)
      Sets the data attribute of the Polynomial object
      Parameters:
      yArr - Y data array
      yErrArr - Y values error array
      xArr - The new data value
    • setData

      public void setData(double[] xArr, double[] yArr)
      Sets the data attribute of the Polynomial object
      Parameters:
      yArr - Y data array
      xArr - The new data value
    • clear

      public void clear()
      Removes all internal data
    • setOrder

      public void setOrder(int n)
      Sets the order of the Polynomial object
      Parameters:
      n - The new order value
    • getOrder

      public int getOrder()
      Returns the order of the Polynomial object
      Returns:
      The order
    • addData

      public void addData(double x, double y)
      Adds a data point to the internal data
      Parameters:
      x - The x value
      y - The y value
    • addData

      public void addData(double x, double y, double yErr)
      Adds a data point to the internal data
      Parameters:
      x - The x value
      y - The y value
      yErr - The error of the y value
    • fit

      public boolean fit()
      It performs one step of the data fit
      Returns:
      Success or not
    • fitFromCenter

      public boolean fitFromCenter()
      It performs one step of the data fit by using centered data. This method could be more accurate in some cases, but you cannot use masks to eliminate fitting of some polynomial coefficients.
      Returns:
      Success or not
    • getValue

      public double getValue(double x)
      Returns the value of Polynomial function
      Parameters:
      x - The x-value
      Returns:
      The polynomial function value
    • getValue

      public double getValue(double x, double[] a)
      Returns the value of Polynomial function
      Parameters:
      x - The x-value
      a - The array of coefficients
      Returns:
      The polynomial equation value
    • getCoefficients

      public double[] getCoefficients()
      Returns the array with the coefficients of the Polynomial
      Returns:
      The array with the coefficients of the Polynomial
    • getCoefficientsErr

      public double[] getCoefficientsErr()
      Returns the array with the errors of the coefficients of the Polynomial
      Returns:
      The array with the errors of the coefficients of the Polynomial
    • equation

      public String equation()
      Return the characteristic equation as a String
      Returns:
      The characteristic equation as a String
    • main

      public static void main(String[] args)
      MAIN for debugging
      Parameters:
      args - The array of strings as parameters