Package xal.extension.fit.lsm
Class Polynomial
java.lang.Object
xal.extension.fit.lsm.Polynomial
This class is for data fitting with polynomial equation.
- Author:
- shishlo
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of PolynomialPolynomial
(int n) Creates a new instance of Polynomial -
Method Summary
Modifier and TypeMethodDescriptionvoid
addData
(double x, double y) Adds a data point to the internal datavoid
addData
(double x, double y, double yErr) Adds a data point to the internal datavoid
clear()
Removes all internal dataequation()
Return the characteristic equation as a Stringboolean
fit()
It performs one step of the data fitboolean
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 fittingvoid
fitParameter
(int index, boolean fitting) Includes or excludes the parameter into fittingdouble[]
Returns the array with the coefficients of the Polynomialdouble[]
Returns the array with the errors of the coefficients of the Polynomialint
getOrder()
Returns the order of the Polynomial objectdouble
getParameter
(int index) Returns the parameter valuedouble
getParameterError
(int index) Returns the parameter value errordouble
getValue
(double x) Returns the value of Polynomial functiondouble
getValue
(double x, double[] a) Returns the value of Polynomial functionstatic void
MAIN for debuggingvoid
setData
(double[] xArr, double[] yArr) Sets the data attribute of the Polynomial objectvoid
setData
(double[] xArr, double[] yArr, double[] yErrArr) Sets the data attribute of the Polynomial objectvoid
setOrder
(int n) Sets the order of the Polynomial objectvoid
setParameter
(int index, double val) Sets the parameter value
-
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 polynomialfitting
- 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 valueindex
- 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 arrayyErrArr
- Y values error arrayxArr
- The new data value
-
setData
public void setData(double[] xArr, double[] yArr) Sets the data attribute of the Polynomial object- Parameters:
yArr
- Y data arrayxArr
- 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 valuey
- 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 valuey
- The y valueyErr
- 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-valuea
- 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
Return the characteristic equation as a String- Returns:
- The characteristic equation as a String
-
main
MAIN for debugging- Parameters:
args
- The array of strings as parameters
-