numpy.polynomial.chebyshev.chebfit(x, y, deg, rcond=None, full=False, w=None)
Least squares fit of Chebyshev series to data.
Return the coefficients of a Chebyshev series of degree
deg that is the least squares fit to the data values
y given at points
y is 1-D the returned coefficients will also be 1-D. If
y is 2-D multiple fits are done, one for each column of
y, and the resulting coefficients are stored in the corresponding columns of a 2-D return. The fitted polynomial(s) are in the form
The solution is the coefficients of the Chebyshev series
p that minimizes the sum of the weighted squared errors
where are the weights. This problem is solved by setting up as the (typically) overdetermined matrix equation
V is the weighted pseudo Vandermonde matrix of
c are the coefficients to be solved for,
w are the weights, and
y are the observed values. This equation is then solved using the singular value decomposition of
If some of the singular values of
V are so small that they are neglected, then a
RankWarning will be issued. This means that the coefficient values may be poorly determined. Using a lower order fit will usually get rid of the warning. The
rcond parameter can also be set to a value smaller than its default, but the resulting fit may be spurious and have large contributions from roundoff error.
Fits using Chebyshev series are usually better conditioned than fits using power series, but much can depend on the distribution of the sample points and the smoothness of the data. If the quality of the fit is inadequate splines may be a good alternative.
|||Wikipedia, “Curve fitting”, https://en.wikipedia.org/wiki/Curve_fitting|
© 2005–2019 NumPy Developers
Licensed under the 3-clause BSD License.