Class DoubleSymmetricGaussian

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

public class DoubleSymmetricGaussian extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The "amplitude0" parameter
    static final String
    The "center" parameter
    static final String
    The "center0" parameter
    static final String
    The "center1" parameter
    static final String
    The "pedestal" parameter
    static final String
    The "sigma0" parameter
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance of Gaussian
  • 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
    boolean
    fit()
    perform one step of the data fit
    boolean
    fit(int iteration)
    perform the data fit
    boolean
    Returns the boolean variable about including variable into the fitting
    void
    fitParameter(String key, boolean incl)
    Includes or excludes the parameter into fitting
    double
    Returns the parameter value
    double
    Returns the parameter value error
    double
    getValue(double x)
    Returns the value of Gaussian function
    boolean
    Finds the parameters of Gaussian with initial values defined from raw data
    boolean
    guessAndFit(int iteration)
    Perform the several iterations of the data fit with guessing the initial values of parameters
    static void
    main(String[] args)
    MAIN for debugging
    void
    setData(double[] xArr, double[] yArr)
    Sets the data attribute of the Gaussian object
    void
    setData(double[] xArr, double[] yArr, double[] yErrArr)
    Sets the data attribute of the Gaussian object
    void
    setParameter(String key, double val)
    Sets the parameter value

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • DoubleSymmetricGaussian

      public DoubleSymmetricGaussian()
      Creates a new instance of Gaussian
  • Method Details

    • getParameter

      public double getParameter(String key)
      Returns the parameter value
      Parameters:
      key - The parameter name
      Returns:
      The parameter value
    • getParameterError

      public double getParameterError(String key)
      Returns the parameter value error
      Parameters:
      key - The parameter name
      Returns:
      The parameter value error
    • fitParameter

      public void fitParameter(String key, boolean incl)
      Includes or excludes the parameter into fitting
      Parameters:
      key - The parameter name
      incl - The boolean variable about including variable into the fitting
    • fitParameter

      public boolean fitParameter(String key)
      Returns the boolean variable about including variable into the fitting
      Parameters:
      key - The parameter name
    • setParameter

      public void setParameter(String key, double val)
      Sets the parameter value
      Parameters:
      key - The parameter name
      val - 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 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 Gaussian object
      Parameters:
      yArr - Y data array
      xArr - 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 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(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

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