Class ErfFitter

All Implemented Interfaces:
IFitStringGetter, IFitter

public final class ErfFitter extends ALeastSquaresFitter
Nonlinear least-squares fitter for scaled/shifted erf:
 y(x) = A * erf((x - x0) / sigma) + B
 

Parameter ordering

  • params[0] = A
  • params[1] = x0
  • params[2] = sigma
  • params[3] = B

Enforces sigma >= DEFAULT_MIN_SIGMA by default.

  • Field Details

  • Constructor Details

    • ErfFitter

      public ErfFitter()
      Create an Erf fitter with default optimizer (Levenberg-Marquardt).
    • ErfFitter

      public ErfFitter(org.apache.commons.math3.fitting.leastsquares.LeastSquaresOptimizer optimizer)
      Create an Erf fitter with the given optimizer.
      Parameters:
      optimizer - the least-squares optimizer to use
  • Method Details

    • getParameterCount

      protected int getParameterCount()
      Specified by:
      getParameterCount in class ALeastSquaresFitter
      Returns:
      number of parameters for this fitter.
    • model

      protected org.apache.commons.math3.fitting.leastsquares.MultivariateJacobianFunction model(double[] x)
      Description copied from class: ALeastSquaresFitter
      Build the model + analytic (or numeric) Jacobian for this fitter, given x values.
      Specified by:
      model in class ALeastSquaresFitter
      Parameters:
      x - x data (length n)
      Returns:
      a MultivariateJacobianFunction compatible with Commons Math least-squares
    • defaultInitialGuess

      protected double[] defaultInitialGuess(double[] x, double[] y, double[] weights)
      Description copied from class: ALeastSquaresFitter
      Default initial guess used if the caller does not provide an explicit override. The default implementation delegates to the ALeastSquaresFitter.initialGuesser.

      Subclasses may override if they have a better model-specific guess.

      Overrides:
      defaultInitialGuess in class ALeastSquaresFitter
      Parameters:
      x - x data
      y - y data
      weights - optional weights (may be null)
      Returns:
      initial parameter vector of length ALeastSquaresFitter.getParameterCount()
    • defaultValidator

      protected org.apache.commons.math3.fitting.leastsquares.ParameterValidator defaultValidator()
      Description copied from class: ALeastSquaresFitter
      Default validator/bounds policy (optional).

      Return null for "no validation". For simple bound constraints, consider using ALeastSquaresFitter.clampingValidator(double[], double[]).

      Overrides:
      defaultValidator in class ALeastSquaresFitter
      Returns:
      a parameter validator or null
    • fit

      public FitResult fit(double[] x, double[] y, double[] weights, ErfFitter.ParameterBounds bounds, double[] initialGuess)
      Expert overload: fit with optional weights, optional bounds, and optional initial guess.
      Parameters:
      x - x data
      y - y data
      weights - optional weights (typically 1/sigmaY^2), may be null
      bounds - optional bounds, may be null
      initialGuess - optional initial guess, may be null
      Returns:
      fit result
    • asEvaluator

      public Evaluator asEvaluator(FitResult fit)
      Description copied from class: ALeastSquaresFitter
      Create an evaluator for the fit result.
      Specified by:
      asEvaluator in class ALeastSquaresFitter
      Parameters:
      fit - the fit result
      Returns:
      an evaluator
    • modelName

      public String modelName()
      Returns:
      model name suitable for a legend or report
    • functionForm

      public String functionForm()
      Returns:
      mathematical function form suitable for display
    • parameterName

      public String parameterName(int index)
      Get the parameter name for the given index.
      Parameters:
      index - the parameter index
      Returns:
      the parameter name
    • getStringGetter

      public IFitStringGetter getStringGetter()
      Description copied from class: ALeastSquaresFitter
      Get the descriptive string getter for this fitter.
      Specified by:
      getStringGetter in class ALeastSquaresFitter
      Returns:
      the string getter