numpy.polynomial.chebyshev.Chebyshev.fit

static Chebyshev.fit(x, y, deg, domain=None, rcond=None, full=False, w=None, window=[-1, 1])

Least squares fit to data.

Return a Chebyshev instance that is the least squares fit to the data y sampled at x. Unlike chebfit, the domain of the returned instance can be specified and this will often result in a superior fit with less chance of ill conditioning. Support for NA was added in version 1.7.0. See chebfit for full documentation of the implementation.

Parameters :

x : array_like, shape (M,)

x-coordinates of the M sample points (x[i], y[i]).

y : array_like, shape (M,) or (M, K)

y-coordinates of the sample points. Several data sets of sample points sharing the same x-coordinates can be fitted at once by passing in a 2D-array that contains one dataset per column.

deg : int

Degree of the fitting polynomial.

domain : {None, [beg, end], []}, optional

Domain to use for the returned Chebyshev instance. If None, then a minimal domain that covers the points x is chosen. If [] the default domain [-1,1] is used. The default value is [-1,1] in numpy 1.4.x and None in later versions. The '[] value was added in numpy 1.5.0.

rcond : float, optional

Relative condition number of the fit. Singular values smaller than this relative to the largest singular value will be ignored. The default value is len(x)*eps, where eps is the relative precision of the float type, about 2e-16 in most cases.

full : bool, optional

Switch determining nature of return value. When it is False (the default) just the coefficients are returned, when True diagnostic information from the singular value decomposition is also returned.

w : array_like, shape (M,), optional

Weights. If not None the contribution of each point (x[i],y[i]) to the fit is weighted by w[i]. Ideally the weights are chosen so that the errors of the products w[i]*y[i] all have the same variance. The default value is None. .. versionadded:: 1.5.0

window : {[beg, end]}, optional

Window to use for the returned Chebyshev instance. The default value is [-1,1] .. versionadded:: 1.6.0

Returns :

least_squares_fit : instance of Chebyshev

The Chebyshev instance is the least squares fit to the data and has the domain specified in the call.

[residuals, rank, singular_values, rcond] : only if full = True

Residuals of the least squares fit, the effective rank of the scaled Vandermonde matrix and its singular values, and the specified value of rcond. For more details, see linalg.lstsq.

See also

chebfit
similar function

Previous topic

numpy.polynomial.chebyshev.Chebyshev.deriv

Next topic

numpy.polynomial.chebyshev.Chebyshev.fromroots

This Page