Documentation of 'jhplot.HFitter' Java class.
HFitter
jhplot

Class HFitter

  • All Implemented Interfaces:
    java.io.Serializable


    public class HFitter
    extends java.lang.Object
    implements java.io.Serializable
    Fit data (H1D or P1D). Some details can be found in http://confluence.slac.stanford .edu/display/JAS3/Functions+and+Fitting+Users+Guide
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      HFitter()
      Create a fitter with the Chi2 method by default.
      HFitter(java.lang.String method)
      Create a fitter using some method.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addFunc(java.lang.String name, IFunction f)
      Add a new function to catalog.
      void doc()
      Show online documentation.
      void fit(H1D h1d)
      Fit histogram
      void fit(H2D h2d)
      Fit H2D histogram
      void fit(P1D p1d)
      Fit P1D
      void fit(PND pnd)
      Fit PND (all errors set to be zero).
      java.lang.String[] getFitEngines()
      Return available fit engines.
      java.lang.String getFitMethod()
      Returns the current fit method.
      java.lang.String[] getFitMethods()
      Return available fit methods.
      IFunction getFittedFunc()
      Get results of the fit in form of function
      IFitter getFitter()
      Return Jaida fitter
      IFunction getFunc()
      Return function
      java.lang.String[] getFuncCatalog()
      Return list of available functions
      double getPar(java.lang.String name)
      Get parameter value
      IFitResult getResult()
      Get result of the fit.
      void setFitMethod(java.lang.String method)
      Sets the fit method.
      void setFunc(IFunction func)
      Set fit functions
      void setFunc(java.lang.String func)
      Set fit functions from predefined string.
      void setFunc(java.lang.String name, int dimension, java.lang.String function, java.lang.String parameters)
      Set functions from a script.
      void setPar(java.lang.String name, double value)
      Set parameter to a value
      void setParConstraint(java.lang.String constraint)
      Set parameter constraint Example: Set parameter "mean1" to be identical to "mean2" as: "mean1=mean2"
      void setParFixed(java.lang.String name)
      Fix a given parameter to a constant value
      void setParFixed(java.lang.String name, boolean fix)
      Fix a given parameter to a constant value or not
      void setParRange(java.lang.String name, double min, double max)
      Set range for parameter during the fit
      void setParStep(java.lang.String name, double step)
      Set step size for parameter (say 0.01)
      void setRange(double rmin, double rmax)
      Set range for fitting for 1D objects (H1D, P1D)
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HFitter

        public HFitter(java.lang.String method)
        Create a fitter using some method. The supported types are:
        uml - unbinned maximum likelihood
        leastsquares - least Squares
        cleverchi2 - "clever" chi2
        chi2 - Chi2 (default)
        bml - binned maximum likelihood

        When a function is provided to the fitter the user has to be aware that the AIDA prescription is to leave the input function unchanged, create a clone, do the fit on the clone and return the clone in the fit result. There advantage to this approach is that the input function can be reused as is for multiple identical fits while the fitted-cloned function is left unchanged in the fit result. The default is noClone=false.

        Parameters:
        method - the fit method (Could be: uml, leastsquares, cleverchi2, chi2, bml)
      • HFitter

        public HFitter()
        Create a fitter with the Chi2 method by default.
    • Method Detail

      • getFitMethods

        public java.lang.String[] getFitMethods()
        Return available fit methods.
        Returns:
        Fit methods
      • getFitMethod

        public java.lang.String getFitMethod()
        Returns the current fit method.
        Returns:
        Fit methods
      • setFitMethod

        public void setFitMethod(java.lang.String method)
        Sets the fit method. Available methods are: uml, leastsquares, cleverchi2, chi2, bml.
        Parameters:
        The - fit method.
      • addFunc

        public void addFunc(java.lang.String name,
                            IFunction f)
        Add a new function to catalog.
        Parameters:
        name - function name
        f - input function
      • getFitEngines

        public java.lang.String[] getFitEngines()
        Return available fit engines.
        Returns:
        Fit methods
      • setFunc

        public void setFunc(IFunction func)
        Set fit functions
      • getFuncCatalog

        public java.lang.String[] getFuncCatalog()
        Return list of available functions
        Returns:
        list of functions
      • setFunc

        public void setFunc(java.lang.String func)
        Set fit functions from predefined string.
        G - Gaussian
        E - Exponential
        Pn' - Polynomial (n is an integer, i.e "P0","P1", "P2').
        Parameters:
        func - string: G (Gaussian),E (exponential),landau (landa),pow (power law), and polynomial: P0,P1,P2,P3..
      • getPar

        public double getPar(java.lang.String name)
        Get parameter value
        Parameters:
        name - parameter name
        Returns:
        value
      • setPar

        public void setPar(java.lang.String name,
                           double value)
        Set parameter to a value
        Parameters:
        name - parameter name
        value - value to be set.
      • setParStep

        public void setParStep(java.lang.String name,
                               double step)
        Set step size for parameter (say 0.01)
        Parameters:
        name - parameter name
        step - step used in minimization
      • setParFixed

        public void setParFixed(java.lang.String name)
        Fix a given parameter to a constant value
        Parameters:
        name - parameter name to be fixed
      • setParFixed

        public void setParFixed(java.lang.String name,
                                boolean fix)
        Fix a given parameter to a constant value or not
        Parameters:
        name - parameter name to be fixed or not
        fix - true if the parameter should be fixed.
      • setParRange

        public void setParRange(java.lang.String name,
                                double min,
                                double max)
        Set range for parameter during the fit
        Parameters:
        name - parameter name
        min - min value
        max - max value
      • setParConstraint

        public void setParConstraint(java.lang.String constraint)
        Set parameter constraint Example: Set parameter "mean1" to be identical to "mean2" as: "mean1=mean2"
        Parameters:
        constraint -
      • getFunc

        public IFunction getFunc()
        Return function
        Returns:
        function
      • setFunc

        public void setFunc(java.lang.String name,
                            int dimension,
                            java.lang.String function,
                            java.lang.String parameters)
        Set functions from a script. Example:
        P2 : setFunc("p2", 1, "a+b*x[0]+c*x[0]*x[0]", "a,b,c")
        parabola : setFunc('parabola',1, 'a*x[0]*x[0]+b*x[0]+c','a,b,c')

        Parameters:
        name - function name
        dimension - dimension
        function - string representing a function
        parameters - parameters (use comma)
      • fit

        public void fit(H1D h1d)
        Fit histogram
        Parameters:
        h1d - input H1D
      • fit

        public void fit(P1D p1d)
        Fit P1D
        Parameters:
        p1d - input P1D
      • fit

        public void fit(PND pnd)
        Fit PND (all errors set to be zero). Only last component is "value" of the data, other are positions in dimension-1 space.
        Parameters:
        pnd - input P1D
      • fit

        public void fit(H2D h2d)
        Fit H2D histogram
        Parameters:
        h2d - input H2D histogram
      • setRange

        public void setRange(double rmin,
                             double rmax)
        Set range for fitting for 1D objects (H1D, P1D)
        Parameters:
        rmin - Min X value
        rmax - Max Y value
      • getFitter

        public IFitter getFitter()
        Return Jaida fitter
        Returns:
        fitter
      • getFittedFunc

        public IFunction getFittedFunc()
        Get results of the fit in form of function
        Returns:
        results of the fit in form of function.
      • getResult

        public IFitResult getResult()
        Get result of the fit.
        Returns:
        result of the fit.
      • doc

        public void doc()
        Show online documentation.

DMelt 3.0 © DataMelt by jWork.ORG