Class SimpleCurveFitter

java.lang.Object
org.apache.commons.math3.fitting.AbstractCurveFitter
org.apache.commons.math3.fitting.SimpleCurveFitter

public class SimpleCurveFitter extends AbstractCurveFitter
Fits points to a user-defined function.
Since:
3.4
  • Field Details

    • function

      private final ParametricUnivariateFunction function
      Function to fit.
    • initialGuess

      private final double[] initialGuess
      Initial guess for the parameters.
    • maxIter

      private final int maxIter
      Maximum number of iterations of the optimization algorithm.
  • Constructor Details

    • SimpleCurveFitter

      private SimpleCurveFitter(ParametricUnivariateFunction function, double[] initialGuess, int maxIter)
      Contructor used by the factory methods.
      Parameters:
      function - Function to fit.
      initialGuess - Initial guess. Cannot be null. Its length must be consistent with the number of parameters of the function to fit.
      maxIter - Maximum number of iterations of the optimization algorithm.
  • Method Details

    • create

      public static SimpleCurveFitter create(ParametricUnivariateFunction f, double[] start)
      Creates a curve fitter. The maximum number of iterations of the optimization algorithm is set to Integer.MAX_VALUE.
      Parameters:
      f - Function to fit.
      start - Initial guess for the parameters. Cannot be null. Its length must be consistent with the number of parameters of the function to fit.
      Returns:
      a curve fitter.
      See Also:
    • withStartPoint

      public SimpleCurveFitter withStartPoint(double[] newStart)
      Configure the start point (initial guess).
      Parameters:
      newStart - new start point (initial guess)
      Returns:
      a new instance.
    • withMaxIterations

      public SimpleCurveFitter withMaxIterations(int newMaxIter)
      Configure the maximum number of iterations.
      Parameters:
      newMaxIter - maximum number of iterations
      Returns:
      a new instance.
    • getProblem

      protected LeastSquaresProblem getProblem(Collection<WeightedObservedPoint> observations)
      Creates a least squares problem corresponding to the appropriate curve.
      Specified by:
      getProblem in class AbstractCurveFitter
      Parameters:
      observations - Sample points.
      Returns:
      the least squares problem to use for fitting the curve to the given points.