## 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 $

Field Summary
`private int` `degree` Polynomial degree.

Constructor Summary
`PolynomialFitter(int degree, DifferentiableMultivariateVectorOptimizer optimizer)` Simple constructor.

Method Summary
`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`

Field Detail

### degree

    private final int degree

  Polynomial degree.

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 (c) 2003-2013 Apache Software Foundation