0
我想用一个最小二乘法找到适合下列数据的抛物线方程。下面的代码工作显然是错误的等式。我是否使用错误的功能来做到这一点?我的数组是(x,y)格式。抛物线拟合数据
import numpy as np
points = np.array ([(0.05, 0.957), (0.12, 0.851), (0.15, 0.832), (0.30, 0.720),
(0.45, 0.583), (0.70, 0.378), (0.84, 0.295), (1.05, 0.156)])
x = points[:,0]
y = points[:,1]
a = np.polyfit(x, y, 2)
b = np.poly1d(a)
print(a)
print (b)
import matplotlib.pyplot as plt
plt.plot(x,y)
plt.plot(b)
plt.show()
b是可调用的,你可能想将它应用到x –