AbstractCurveFitter (Apache Commons Math 3.3 API)

org.apache.commons.math3.fitting

## Class AbstractCurveFitter

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

- Direct Known Subclasses:
    GaussianCurveFitter, HarmonicCurveFitter, PolynomialCurveFitter

      public abstract class AbstractCurveFitter
      extends Object

  Base class that contains common code for fitting parametric univariate real functions `y = f(pi;x)`, where `x` is the independent variable and the `pi` are the parameters.
  A fitter will find the optimal values of the parameters by fitting the curve so it remains very close to a set of `N` observed points `(xk, yk)`, `0 <= k < N`.
  An algorithm usually performs the fit by finding the parameter values that minimizes the objective function

        ∑yk - f(xk)2,

  which is actually a least-squares problem. This class contains boilerplate code for calling the `fit(Collection)` method for obtaining the parameters. The problem setup, such as the choice of optimization algorithm for fitting a specific function is delegated to subclasses.
  Since:
    3.3
  Version:
    $Id: AbstractCurveFitter.java 1569358 2014-02-18 14:33:20Z luc $

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected static class` | `AbstractCurveFitter.TheoreticalValuesFunction` Vector function for computing function theoretical values.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractCurveFitter()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `double[]` | `fit(Collection<WeightedObservedPoint> points)` Fits a curve.
    `protected LeastSquaresOptimizer` | `getOptimizer()` Creates an optimizer set up to fit the appropriate curve.
    `protected abstract LeastSquaresProblem` | `getProblem(Collection<WeightedObservedPoint> points)` Creates a least squares problem corresponding to the appropriate curve.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractCurveFitter

          public AbstractCurveFitter()

  - ### Method Detail

    - #### fit

          public double[] fit(Collection<WeightedObservedPoint> points)

      Fits a curve. This method computes the coefficients of the curve that best fit the sample of observed points.
      Parameters:
        `points` - Observations.
      Returns:
        the fitted parameters.

    - #### getOptimizer

          protected LeastSquaresOptimizer getOptimizer()

      Creates an optimizer set up to fit the appropriate curve.

      The default implementation uses a `Levenberg-Marquardt` optimizer.

      Returns:
        the optimizer to use for fitting the curve to the given `points`.

    - #### getProblem

          protected abstract LeastSquaresProblem getProblem(Collection<WeightedObservedPoint> points)

      Creates a least squares problem corresponding to the appropriate curve.
      Parameters:
        `points` - Sample points.
      Returns:
        the least squares problem to use for fitting the curve to the given `points`.

Copyright © 2003–2014 The Apache Software Foundation. All rights reserved.