Fit a polynomial p(x)=p[0]*x**deg+...+p[deg] of degree deg
to points (x, y). Returns a vector of coefficients p that minimises
the squared error.

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

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 to apply to the y-coordinates of the sample points.

cov : bool, optional

Return the estimate and the covariance matrix of the estimate
If full is True, then cov is not returned.

Returns :

p : ndarray, shape (M,) or (M, K)

Polynomial coefficients, highest power first.
If y was 2-D, the coefficients for k-th data set are in p[:,k].

residuals, rank, singular_values, rcond : present only if full = True

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

V : ndaray, shape (M,M) or (M,M,K)

The covariance matrix of the polynomial coefficient estimates. The diagonal
of this matrix are the variance estimates for each coefficient. If y is a 2-d
array, then the covariance matrix for the k-th data set are in V[:,:,k]

Warns :

RankWarning

The rank of the coefficient matrix in the least-squares fit is
deficient. The warning is only raised if full = False.