Class Fit

java.lang.Object
cnuphys.splot.fit.Fit

public class Fit extends Object
General Fit container class. It holds all the information for a fit, but the actual fit is performed by the object held in the _fit instance variable, which is a numerical recipes fit object.
Author:
heddle
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static enum 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Fit()
     
    Fit(double[] x, double[] y, double[] sigmaY)
     
    Fit(double[] x, double[] y, double[] sigmaY, double tolerance)
    Create a fit which is someone poorly named.
    Fit(double[] x, double[] y, double[] sigmaX, double[] sigmaY, double tolerance)
    Create a fit which is someone poorly named.
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the error type that was used in the fitting
    Returns the fit object, which is most likely a numerical recipes fit
    Get a report on the fit parameters in html
    Get the fit type
    protected Vector<FitHold>
    Get the fit parameter holds
    int
    Get the number of gaussians
    int
    Get the polynomial order, the polynomial order--the power of the highest power
    double[]
    Get the x error data for the fit
    double[]
    Get the y error data for the fit
    double
    Get the tolerance
    double[]
    Get the x data for the fit
    double[]
    Get the y data for the fit
    void
    hold(int index, double val)
    Set a hold on a fit parameter.
    boolean
    Check whether fit needs to be recomputed
    boolean
    isHeld(int index)
    Check whether a parameter was held
    static void
    main(String[] arg)
     
    void
    Set the fit to be dirty.
    protected void
    Set the error type used by the fitting.
    void
    Set the fit
    void
    Set the fit type
    void
    setNumGaussian(int numGauss)
    Set the number of gaussians
    void
    setPolynomialOrder(int order)
    Get the polynomial order--the power of the highest power
    void
    setSigmaX(double[] sigma)
    Set the x error data for the fit
    void
    setSigmaY(double[] sigma)
    Set the y error data for the fit
    void
    setTolerance(double tolerance)
    Set the tolerance
    void
    setX(double[] x)
    Set the x data for the fit
    void
    setY(double[] y)
    Set the y data for the fit
    int
    The x and y data arrays should be the same size.

    Methods inherited from class java.lang.Object

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

    • Fit

      public Fit()
    • Fit

      public Fit(double[] x, double[] y, double[] sigmaY)
    • Fit

      public Fit(double[] x, double[] y, double[] sigmaY, double tolerance)
      Create a fit which is someone poorly named. It is really just a container that holds all the data for a fit. It will be used in the constructor of an actual fit.
      Parameters:
      x - the x data
      y - the y data
      sigmaY - the y errors
      tolerance - accuracy parameter (for nonlinear fits)
    • Fit

      public Fit(double[] x, double[] y, double[] sigmaX, double[] sigmaY, double tolerance)
      Create a fit which is someone poorly named. It is really just a container that holds all the data for a fit. It will be used in the constructor of an actual fit.
      Parameters:
      x - the x data
      y - the y data
      sigmaX - the x errors
      sigmaY - the y errors
      tolerance - accuracy parameter (for nonlinear fits)
  • Method Details

    • size

      public int size()
      The x and y data arrays should be the same size. This returns the smaller of the two sizes.
      Returns:
      the minimum size of the data arrays
    • hold

      public void hold(int index, double val)
      Set a hold on a fit parameter. If there already is one it will be overwritten using the new value.
      Parameters:
      index - the index of the parameter
      val - the value at which the parameter is held.
    • getHolds

      protected Vector<FitHold> getHolds()
      Get the fit parameter holds
      Returns:
      the fit parameter holds
    • isHeld

      public boolean isHeld(int index)
      Check whether a parameter was held
      Parameters:
      index - the index of the parameter
      Returns:
      true if the index was held
    • getX

      public double[] getX()
      Get the x data for the fit
      Returns:
      the x data for the fit
    • getY

      public double[] getY()
      Get the y data for the fit
      Returns:
      the y data for the fit
    • getSigmaY

      public double[] getSigmaY()
      Get the y error data for the fit
      Returns:
      the y error data for the fit
    • getSigmaX

      public double[] getSigmaX()
      Get the x error data for the fit
      Returns:
      the x error data for the fit
    • setX

      public void setX(double[] x)
      Set the x data for the fit
      Parameters:
      x - the x data
    • setY

      public void setY(double[] y)
      Set the y data for the fit
      Parameters:
      y - the y data
    • setSigmaY

      public void setSigmaY(double[] sigma)
      Set the y error data for the fit
      Parameters:
      sigma - the y error data
    • setSigmaX

      public void setSigmaX(double[] sigma)
      Set the x error data for the fit
      Parameters:
      sigma - the x error data
    • setErrorType

      protected void setErrorType(Fit.ErrorType errorType)
      Set the error type used by the fitting. The client does no set this, the methods that call the fits in FitUtilities set this. If the type is "Massaged zeroes" it meant that error of zero were given fake fakes (equal to the mean error) to prevent the fits from failing.
      Parameters:
      errorType - the way the errors were used.
    • getErrorType

      public Fit.ErrorType getErrorType()
      Get the error type that was used in the fitting
      Returns:
      the error type that was used in the fitting
    • setPolynomialOrder

      public void setPolynomialOrder(int order)
      Get the polynomial order--the power of the highest power
      Parameters:
      order - the polynomial order--the power of the highest power
    • getPolynomialOrder

      public int getPolynomialOrder()
      Get the polynomial order, the polynomial order--the power of the highest power
      Returns:
      the polynomial order
    • getNumGaussian

      public int getNumGaussian()
      Get the number of gaussians
      Returns:
      the number of gaussians
    • setNumGaussian

      public void setNumGaussian(int numGauss)
      Set the number of gaussians
      Parameters:
      numGauss - the new number of gaussians
    • setTolerance

      public void setTolerance(double tolerance)
      Set the tolerance
      Parameters:
      tolerance - the value of the tolerance
    • getTolerance

      public double getTolerance()
      Get the tolerance
      Returns:
      the tolerance
    • getFit

      public Object getFit()
      Returns the fit object, which is most likely a numerical recipes fit
      Returns:
      the fit object.
    • setFit

      public void setFit(Object fit)
      Set the fit
      Parameters:
      fit - the new fit object, which is most likely a numerical recipes fit
    • setDirty

      public void setDirty()
      Set the fit to be dirty. Perhaps more data have been added
    • isDirty

      public boolean isDirty()
      Check whether fit needs to be recomputed
      Returns:
      true if fit must be recomputed
    • getFitType

      public FitType getFitType()
      Get the fit type
      Returns:
      the fit type
    • setFitType

      public void setFitType(FitType type)
      Set the fit type
      Parameters:
      type - the fit type
    • getFitString

      public String getFitString(DataColumn curve)
      Get a report on the fit parameters in html
      Parameters:
      curve - the active curve
      Returns:
      the html fit string description
    • main

      public static void main(String[] arg)