numpy.polyfit()

numpy.polyfit

numpy.polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False) [source]

Least squares polynomial fit.

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 :