Parameters of the polynomial equation

I have some 2D sampling points for which I need a polynomial equation. I found something like this:

from scipy.interpolate import barycentric_interpolate
// x and y are given as lists
yi = barycentric_interpolate(x, y, xi)

But in this case, I can only get y values โ€‹โ€‹belonging to some xi values โ€‹โ€‹- this is not what I want. I need an equation (parameter for polynomial equation). How can i get this?

0
source share
2 answers

numpy.polyfit

We put the polynomial p (x) = p [0] * x ** deg + ... + p [deg] of degree deg to the points (x, y). Returns a coefficient vector p that minimizes the square error.

Example from the docs:

>>> x = np.array([0.0, 1.0, 2.0, 3.0,  4.0,  5.0])
>>> y = np.array([0.0, 0.8, 0.9, 0.1, -0.8, -1.0])
>>> z = np.polyfit(x, y, 3)
>>> z
array([ 0.08703704, -0.81349206,  1.69312169, -0.03968254])
+2
source

Source: https://habr.com/ru/post/1529640/


All Articles