I'm trying to get the coefficients of a numpy.polynomial.polynomial.Polynomial
obtained via
the fit
method:
import numpy.polynomial as poly
x = [1, 2, 3, 4, 5]
y = [16, 42.25, 81, 132.25, 196]
c = poly.Polynomial.fit(x, y, deg = 2)
print(c(5))
print(c)
This small program prints
196.00000000000006
poly([81. 90. 25.])
which is the correct value for c(5)
but not for the polynomial coefficients, which are 2.25
, 7.5
, and 6.25
.
How do I get the actual coefficients?