org.apache.commons.math3.optimization.fitting

## Class PolynomialFitter

- java.lang.Object
- - org.apache.commons.math3.optimization.fitting.CurveFitter
  - - org.apache.commons.math3.optimization.fitting.PolynomialFitter

-     public class PolynomialFitter
      extends CurveFitter

  This class implements a curve fitting specialized for polynomials.

  Polynomial fitting is a very simple case of curve fitting. The estimated coefficients are the polynomial coefficients. They are searched by a least square estimator.

  Since:
    2.0
  Version:
    $Id: PolynomialFitter.java 1244107 2012-02-14 16:17:55Z erans $

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PolynomialFitter(int degree, DifferentiableMultivariateVectorOptimizer optimizer)` Simple constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `double[]` | `fit()` Get the polynomial fitting the weighted (x, y) points.

    - ### Methods inherited from class org.apache.commons.math3.optimization.fitting.CurveFitter

      `addObservedPoint, addObservedPoint, addObservedPoint, clearObservations, fit, fit, getObservations`

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

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

- - ### Constructor Detail

    - #### PolynomialFitter

          public PolynomialFitter(int degree,
                          DifferentiableMultivariateVectorOptimizer optimizer)

      Simple constructor.

      The polynomial fitter built this way are complete polynomials, ie. a n-degree polynomial has n+1 coefficients.

      Parameters:
        `degree` - Maximal degree of the polynomial.
        `optimizer` - Optimizer to use for the fitting.

  - ### Method Detail

    - #### fit

          public double[] fit()

      Get the polynomial fitting the weighted (x, y) points.
      Returns:
        the coefficients of the polynomial that best fits the observed points.
      Throws:
        `ConvergenceException` - if the algorithm failed to converge.

Copyright © 2003-2012 The Apache Software Foundation. All Rights Reserved.