Package xal.extension.fit.lsm
Class DoubleSymmetricGaussian
java.lang.Object
xal.extension.fit.lsm.DoubleSymmetricGaussian
This class is for data fitting with two Gaussian functions with the same
center. The function form used in this class is y =
pedestal+amp*exp(-(x-center0)^2/(sigma^2/2.)) +
amp*exp(-(x-center1)^2/(sigma^2/2.)). Users should keep in mind that guess
does not work very well when two peaks are not separated clearly. You should
use nonlinear methods first, and then try the linear approach to get errors
for parameters.
- Author:
- shishlo
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The "amplitude0" parameterstatic final String
The "center" parameterstatic final String
The "center0" parameterstatic final String
The "center1" parameterstatic final String
The "pedestal" parameterstatic final String
The "sigma0" parameter -
Constructor Summary
Constructors -
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 databoolean
fit()
perform one step of the data fitboolean
fit
(int iteration) perform the data fitboolean
fitParameter
(String key) Returns the boolean variable about including variable into the fittingvoid
fitParameter
(String key, boolean incl) Includes or excludes the parameter into fittingdouble
getParameter
(String key) Returns the parameter valuedouble
getParameterError
(String key) Returns the parameter value errordouble
getValue
(double x) Returns the value of Gaussian functionboolean
Finds the parameters of Gaussian with initial values defined from raw databoolean
guessAndFit
(int iteration) Perform the several iterations of the data fit with guessing the initial values of parametersstatic void
MAIN for debuggingvoid
setData
(double[] xArr, double[] yArr) Sets the data attribute of the Gaussian objectvoid
setData
(double[] xArr, double[] yArr, double[] yErrArr) Sets the data attribute of the Gaussian objectvoid
setParameter
(String key, double val) Sets the parameter value
-
Field Details
-
SIGMA_STR
The "sigma0" parameter- See Also:
-
AMP_STR
The "amplitude0" parameter- See Also:
-
CENTER_STR
The "center" parameter- See Also:
-
CENTER0_STR
The "center0" parameter- See Also:
-
CENTER1_STR
The "center1" parameter- See Also:
-
PEDESTAL_STR
The "pedestal" parameter- See Also:
-
-
Constructor Details
-
DoubleSymmetricGaussian
public DoubleSymmetricGaussian()Creates a new instance of Gaussian
-
-
Method Details
-
getParameter
Returns the parameter value- Parameters:
key
- The parameter name- Returns:
- The parameter value
-
getParameterError
Returns the parameter value error- Parameters:
key
- The parameter name- Returns:
- The parameter value error
-
fitParameter
Includes or excludes the parameter into fitting- Parameters:
key
- The parameter nameincl
- The boolean variable about including variable into the fitting
-
fitParameter
Returns the boolean variable about including variable into the fitting- Parameters:
key
- The parameter name
-
setParameter
Sets the parameter value- Parameters:
key
- The parameter nameval
- The new parameter value
-
setData
public void setData(double[] xArr, double[] yArr, double[] yErrArr) Sets the data attribute of the Gaussian 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 Gaussian object- Parameters:
yArr
- Y data arrayxArr
- The new data value
-
clear
public void clear()Removes all internal data -
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(int iteration) perform the data fit- Parameters:
iteration
- The number of iterations- Returns:
- Success or not
-
fit
public boolean fit()perform one step of the data fit- Returns:
- Success or not
-
guessAndFit
public boolean guessAndFit(int iteration) Perform the several iterations of the data fit with guessing the initial values of parameters- Parameters:
iteration
- The number of iterations- Returns:
- Success or not
-
guessAndFit
public boolean guessAndFit()Finds the parameters of Gaussian with initial values defined from raw data- Returns:
- The true is the initial parameters have been defined successfully
-
getValue
public double getValue(double x) Returns the value of Gaussian function- Parameters:
x
- The x-value- Returns:
- The Gauss function value
-
main
MAIN for debugging- Parameters:
args
- The array of strings as parameters
-